summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2011-01-11 15:16:52 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2011-01-11 15:16:52 +0000
commit133922318641d2545df6c45d06b4f4cefc3670fc (patch)
treead14ec2b14bbeaa813cbba0f858fd85dfa5f5c1a /clang/lib/Sema/SemaDecl.cpp
parentc8adf5f4584677007900043e86d012846f485de9 (diff)
downloadbcm5719-llvm-133922318641d2545df6c45d06b4f4cefc3670fc.tar.gz
bcm5719-llvm-133922318641d2545df6c45d06b4f4cefc3670fc.zip
Added warning about invalid register specification for local variables.
llvm-svn: 123236
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 28ae8d23c7b..4d67ff22ac7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2997,10 +2997,24 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// The parser guarantees this is a string.
StringLiteral *SE = cast<StringLiteral>(E);
llvm::StringRef Label = SE->getString();
- if (S->getFnParent() != 0 &&
- !Context.Target.isValidGCCRegisterName(Label))
- Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
- NewVD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0),
+ if (S->getFnParent() != 0) {
+ switch (SC) {
+ case SC_None:
+ case SC_Auto:
+ Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
+ break;
+ case SC_Register:
+ if (!Context.Target.isValidGCCRegisterName(Label))
+ Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
+ break;
+ case SC_Static:
+ case SC_Extern:
+ case SC_PrivateExtern:
+ break;
+ }
+ }
+
+ NewVD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0),
Context, Label));
}
OpenPOWER on IntegriCloud