[cfe-commits] [Patch] Add -Wmissing-variable-declarations
Eli Friedman
eli.friedman at gmail.com
Fri Oct 19 02:34:39 PDT 2012
On Fri, Oct 19, 2012 at 2:03 AM, Ed Schouten <ed at 80386.nl> wrote:
> Hi Eli,
>
> Thanks again for taking your time to review my patch!
>
> 2012/10/19 Eli Friedman <eli.friedman at gmail.com>:
>> + if (var->isThisDeclarationADefinition() &&
>> + (var->getLinkage() == ExternalLinkage ||
>> + var->getLinkage() == UniqueExternalLinkage)) {
>>
>> We don't want to warn for code like the following, which is what
>> UniqueExternalLinkage is used for:
>>
>> namespace {
>> int x;
>> }
>
> The problem is that if I don't check for UniqueExternalLinkage, it
> won't trigger a warning for this code, even though it should:
>
> struct {
> int foo;
> } bar;
In C (or C++ in an 'extern "C"' block), "bar" shouldn't have
UniqueExternalLinkage. In C++, there isn't any reason to warn here:
"bar" can't be referenced from any other translation unit. See
[basic.link]p8 in the standard.
-Eli
More information about the cfe-commits
mailing list