diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-03 04:29:20 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-03 04:29:20 +0000 |
commit | 6769ccb6853871c085c8366ab5e993841ad56d00 (patch) | |
tree | 145e2dea940867ad682d6553e517726852aa0f41 /lib/Sema/SemaDecl.cpp | |
parent | da844b3483669c64d02082ff2a9e68d46bd00c1f (diff) |
Warn on unused auto variables.
To do so we have to wait until we know that the type of a variable has been
deduced. Sema::FinalizeDeclaration is the first callback that is used for
decl with or without initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 624f40582b..61791b2aa5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4537,8 +4537,6 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // member, set the visibility of this variable. if (NewVD->getLinkage() == ExternalLinkage && !DC->isRecord()) AddPushedVisibilityAttribute(NewVD); - - MarkUnusedFileScopedDecl(NewVD); return NewVD; } @@ -7348,6 +7346,9 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) { if (!VD) return; + if (VD->isFileVarDecl()) + MarkUnusedFileScopedDecl(VD); + // Now we have parsed the initializer and can update the table of magic // tag values. if (!VD->hasAttr<TypeTagForDatatypeAttr>() || |