This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc.dg/unused-3.c


>>>>> "Richard" == Richard Henderson <rth@cygnus.com> writes:

    Richard> This appears to fix the later.  I notice that the C++

Thanks for looking at this.

    Richard> front end calls warn_about_unused_variables directly.  Is
    Richard> there a reason?

I bet your change will make us warn twice in C++.

The basic point is that unusedness is a semantic property; it should
be checked when the function is processed, not when it is expanded.
The C++ front-end is smart enough, when confronted with:

  inline void f () { int i; }

and no uses of `f' to not generate RTL for `f' until `f' is called.
However, it still wants to warn about `i' being unused when `f' is
processed.

Ideally, no warnings would come out of the RTL expansion process and
optimization, except for those that involve knowledge learned by the
various machinations of the optimizer, such as used-before-set.

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?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]