Re: [PATCH 3/5] initial parsing of __attribute__((format))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29/10/18 20:41, Luc Van Oostenryck wrote:
On Mon, Oct 29, 2018 at 03:39:50PM +0000, Ben Dooks wrote:
Add code to parse the __attribute__((format)) used to indicate that
a variadic function takes a printf-style format string and where
those are. Save the data in ctype ready for checking when such an
function is encoutered.


In other words, this parsing should not poke into the base type. But as-is
the two args will not be propagated into the function because ctx is for the
whole declaration. You will need to add something like:
	diff --git a/parse.c b/parse.c
	index 83bca24b3..4e273b743 100644
	--- a/parse.c
	+++ b/parse.c
	@@ -2979,6 +2979,10 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
	
	 		if (!(decl->ctype.modifiers & MOD_STATIC))
	 			decl->ctype.modifiers |= MOD_EXTERN;
	+
	+		// apply non-modifier function attributes
	+		base_type->ctype.printf_msg = decl->ctype.printf_msg;
	+		base_type->ctype.printf_va_start = decl->ctype.printf_va_start;
	 	} else if (base_type == &void_ctype && !(decl->ctype.modifiers & MOD_EXTERN)) {
	 		sparse_error(token->pos, "void declaration");
	 	}

and at some later stage, I'll make it more generic.

Ok, thanks. That seems to have worked.


--
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux