On Tue, Feb 28, 2017 at 6:04 PM, Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> wrote: > In C99, it is valid to declare a variable inside a > for-loop initializer but only when the storage is local > (automatic or register). > Until now this was not enforced. > Will apply in sparse-next with some comment. > > +static void process_for_loop_decl(struct symbol_list **list, struct symbol *sym) > +{ > + unsigned long storage; > + > + storage = sym->ctype.modifiers & MOD_STORAGE; > + if (storage & ~(MOD_AUTO | MOD_REGISTER)) { > + const char *name = show_ident(sym->ident); > + sparse_error(sym->pos, "non-local var '%s' in for-loop initializer", name); > + sym->ctype.modifiers &= ~MOD_STORAGE; > + } > + > + add_symbol(list, sym); > + fn_local_symbol(sym); The more I look at it, the more I feel that the above two lines should kind of appear in every process_*_declar function. So may be we should just change your patch 4/7 into: if (!is_typedef) { + if (process_decl) + process_decl(sym); if (!(decl->ctype.modifiers & (MOD_EXTERN | MOD_INLINE))) { add_symbol(list, decl); fn_local_symbol(decl); } } Then for the default case, just pass NULL as process_decl. Might want to find a better name for this function callback arguments as well. Because you are actually not interested in change the behavor of adding to the list at all. You just want to get an notification when the symbol does get added into the list. Now thing of it, I can't come up with one example process_xxx_decl not add the symbol nor doing the fn_local_symbol. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html