[cfe-commits] [Patch] Add -Wmissing-variable-declarations
ed at 80386.nl
Thu Dec 15 07:47:07 PST 2011
* Eli Friedman <eli.friedman at gmail.com>, 20111210 03:38:
> The check should be in CheckCompleteVariableDeclaration, not
Are you sure about this? If I place it in CheckCompleteVariable-
Declaration, I can only emit warnings when saying:
int i = 3;
The intention is that even a regular `int i' generates a compiler
warning. It must be preceded by `extern int i'.
> isThisDeclarationADefinition() to check for a definition, and
> getLinkage() to check whether the declaration is externally visible.
> (The one interesting C testcase here is "extern int x = 3;"; there are
> also various C++ tests of interest, like const globals and a
> definition in an anonymous namespace.)
I'm not a very good compiler hacker so I could use some help here. I
suspect you mean something like this?
if (var->isThisDeclarationADefinition() &&
var->getLinkage() == ExternalLinkage &&
var->getPreviousDeclaration() == NULL)
diag::warn_missing_variable_declarations) << var;
Ed Schouten <ed at 80386.nl>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 834 bytes
Desc: not available
More information about the cfe-commits