[cfe-commits] r166361 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp lib/Sema/SemaExpr.cpp test/CodeGenCXX/const-init-cxx11.cpp test/CodeGenCXX/for-range.cpp test/CodeGenCXX/lambda-expressions.cpp test/SemaCXX/lambda-expressions.cpp

Richard Smith richard at metafoo.co.uk
Fri Oct 26 16:43:01 PDT 2012


On Fri, Oct 26, 2012 at 1:54 PM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> On Oct 26, 2012, at 1:35 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
>> Argyrios: It looks like you added this warning in r129794. Can you
>> comment on what it's intended to detect?
>
> variables/functions with internal linkage that are not used from the codegen perspective.
> This differs from -Wunused which will consider a 'use' even in an unevaluated context.

Why is that a useful thing to warn on?

> For example:
>
> static void foo() { }
>
> this gives:
> warning: unused function 'foo' [-Wunused-function]
>
> static void foo() { }
> template <typename T>
> void goo() {
>   foo();
> }
>
> this gives:
> warning: function 'foo' is not needed and will not be emitted [-Wunneeded-internal-declaration]

That code certainly looks bogus, but I don't think that's the right
warning. We should warn either on the definition of 'goo' (because it
has external linkage but uses an internal linkage function) or warn
that 'goo' is unused and can't be used outside this TU.



More information about the cfe-commits mailing list