diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-17 20:34:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-17 20:34:02 +0000 |
commit | 57ad37823e198f977cac605dbfbaefb4daf325e9 (patch) | |
tree | 6a224b2610fe145e615126e76e465f9cbdf77401 /lib/Sema/SemaDecl.cpp | |
parent | d8e54990ade0dd5566f8e3aa2e62def08753d1e9 (diff) |
Step #2/N of __label__ support: keep pushing LabelDecl forward,
making them be template instantiated in a more normal way and
make them handle attributes like other decls.
This fixes the used/unused label handling stuff, making it use
the same infrastructure as other decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index bcec9d4839..98555d9525 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -629,6 +629,9 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) { if (D->isUsed() || D->hasAttr<UnusedAttr>()) return false; + if (isa<LabelDecl>(D)) + return true; + // White-list anything that isn't a local variable. if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D) || !D->getDeclContext()->isFunctionOrMethod()) @@ -675,12 +678,15 @@ void Sema::DiagnoseUnusedDecl(const NamedDecl *D) { if (!ShouldDiagnoseUnusedDecl(D)) return; + unsigned DiagID; if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable()) - Diag(D->getLocation(), diag::warn_unused_exception_param) - << D->getDeclName(); + DiagID = diag::warn_unused_exception_param; + else if (isa<LabelDecl>(D)) + DiagID = diag::warn_unused_label; else - Diag(D->getLocation(), diag::warn_unused_variable) - << D->getDeclName(); + DiagID = diag::warn_unused_variable; + + Diag(D->getLocation(), DiagID) << D->getDeclName(); } void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { |