summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-17 20:34:02 +0000
committerChris Lattner <sabre@nondot.org>2011-02-17 20:34:02 +0000
commitcab02a60d231b8ca4df80f88689827d8b4cea95e (patch)
tree060d42ab1daa9e8ce9b1d92c55e9014bc5d97e70 /clang/lib/Sema/SemaDecl.cpp
parent50c3c1316a0faf8b3566489aa5030a3f9ed13759 (diff)
downloadbcm5719-llvm-cab02a60d231b8ca4df80f88689827d8b4cea95e.tar.gz
bcm5719-llvm-cab02a60d231b8ca4df80f88689827d8b4cea95e.zip
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. llvm-svn: 125771
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bcec9d48393..98555d9525a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud