compilers don't seem to warn about unused variables in the global scope

And this causes at least some problems with extern variables in headers,
maybe that could be handled, but it probably wouldn't be trivial to
get it exactly right about which location to warn and which ones not.

Change-Id: I8974c9ba9493d09165b026ee7a451238f6d90a30
This commit is contained in:
Luboš Luňák
2012-10-12 15:52:35 +02:00
parent 2acc59ea28
commit cd8a490536

View File

@@ -47,6 +47,8 @@ bool UnusedVariableCheck::VisitNamedDecl( NamedDecl* declaration )
const VarDecl* var = cast< VarDecl >( declaration );
if( var->isReferenced() || var->isUsed())
return true;
if( var->isDefinedOutsideFunctionOrMethod())
return true;
if( CXXRecordDecl* type = var->getType()->getAsCXXRecordDecl())
{
bool warn_unused = false;