gcc.dg/unused-3.c

Richard Henderson rth@cygnus.com
Tue Sep 19 00:58:00 GMT 2000


> The basic point is that unusedness is a semantic property; it should
> be checked when the function is processed, not when it is expanded.
[...]
> So, I would prefer that we make like the C front-end and warn from
> poplevel, rather than from c-semantics.c.  Does that make sense?

Yes.  Completely.


r~


	* c-decl.c (poplevel): Invoke warn_about_unused_variables.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-decl.c,v
retrieving revision 1.159
diff -c -p -d -r1.159 c-decl.c
*** c-decl.c	2000/09/19 02:14:33	1.159
--- c-decl.c	2000/09/19 07:53:46
*************** poplevel (keep, reverse, functionbody)
*** 1100,1105 ****
--- 1100,1111 ----
  	  TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
        }
  
+   /* We used to warn about unused variables in expand_end_bindings,
+      i.e. while generating RTL.  But in function-at-a-time mode we may
+      choose to never expand a function at all (e.g. auto inlining), so
+      we do this explicitly now.  */
+   warn_about_unused_variables (getdecls ());
+ 
    /* If there were any declarations or structure tags in that level,
       or if this level is a function body,
       create a BLOCK to record them for the life of this function.  */


More information about the Gcc-regression mailing list