On Oct 26, 2012, at 4:43 PM, Richard Smith <[email protected]> wrote:
> On Fri, Oct 26, 2012 at 1:54 PM, Argyrios Kyrtzidis <[email protected]> > wrote: >> On Oct 26, 2012, at 1:35 PM, Richard Smith <[email protected]> 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? Because it means you have unused code/data resulting from a bug (bad) or a refactoring (bad hygiene), etc. > >> 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. Here's a more realistic example: static int data1[100]; static int data2[300]; int data1_size() { return sizeof(data1); }; int data2_size() { return sizeof(data2); }; int *get_data1() { return data1; } int *get_data2() { return data1; // Oops, typo. } This gives: warning: variable 'data2' is not needed and will not be emitted [-Wunneeded-internal-declaration] _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
