On Thu, Dec 14, 2023 at 02:05:22PM +0100, Luc Van Oostenryck wrote: > On Wed, Dec 13, 2023 at 01:14:29PM +0300, Dan Carpenter wrote: > > On Tue, Dec 12, 2023 at 12:39:40PM +0300, Dan Carpenter wrote: > > > > > @@ -2924,6 +2945,7 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis > > > > > > > > > > decl->ctype = ctx.ctype; > > > > > decl->ctype.modifiers |= mod; > > > > > + decl->cleanup = ctx.cleanup; > > > > > > > > Similarly, the attribute should only be applied to automatic variables, > > > > so this should not be needed/should be detected as an error. > > > > > > > > > > Yeah. There are a couple other "cleanup" lines later in the function > > > that should be deleted as well, I see. > > > > Hm... Something went wrong. When I remove this assignment then the > > cleanup function isn't saved here: > > Mmmmhh yes, my bad. > I thought that the parsing functions followed closely the names of the > C grammar in the spec. They largely do but not in this case (they can't > because some context is needed to distinguish between 'declaration' and > 'function-definition'). > > Would the following patch be OK for you when applied on top of your v2? > It contains: > - the attribute can be removed from the list of ignored attributes > - I prefer to add the "attribute_cleanup," on its own line > - I added some checks and a few corresponding testcases > - the s/D("__cleanup__"/D("cleanup"/ > - and the removal of 'sym->cleanup = ctx.cleanup;' from typename() which > I think is still unneeded. Yep. Perfect. Thanks so much! regards, dan carpenter