aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-01-01 21:47:03 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-01-01 21:47:03 +0000
commitbaf86955a9a390f2643a1ea9806832eb4a92f716 (patch)
tree5d2e2e6ff6a82f0717c2fb6a07f088ab8e02355c /lib/Sema/SemaDecl.cpp
parent03117d1b2e32d18652401b12d9049871992bf3ad (diff)
Produce a better error message for invalid register names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 62262bc60b..abd63198d4 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2995,8 +2995,12 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
if (Expr *E = (Expr*)D.getAsmLabel()) {
// 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),
- Context, SE->getString()));
+ Context, Label));
}
// Diagnose shadowed variables before filtering for scope.