On 07/27/2011 01:54 PM, Dodji Seketeli wrote:
+ /* Set of typedefs that are used in this function. */ + struct pointer_set_t * GTY((skip)) used_local_typedefs;
Is there a reason not to just use TREE_USED for this?
+ /* Vector of locally defined typedefs, for + -Wunused-local-typedefs. */ + VEC(tree,gc) *local_typedefs;
If the accessors are in c-common, this field should be in c_language_function.
+ /* We are only interested in a typedef declared locally. */ + if (DECL_CONTEXT (typedef_decl) != current_function_decl) + return;
What if it's used in a nested function/local class/lambda?
@@ -4175,6 +4175,9 @@ mark_used (tree decl) /* Set TREE_USED for the benefit of -Wunused. */ TREE_USED (decl) = 1; + + maybe_record_local_typedef_use (TREE_TYPE (decl));
Why is this needed? If the decl has the typedef for a type, we should have already marked it as used in grokdeclarator.
Actually, couldn't we just mark a typedef as used when when lookup finds it? That would avoid having to mark in so many places and avoid the need for walk_tree.
I think -Wunused and -Wall should imply -Wunused-local-typedefs unless the user specifies -Wno-unused-local-typedefs.
Jason