From 133922318641d2545df6c45d06b4f4cefc3670fc Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Tue, 11 Jan 2011 15:16:52 +0000 Subject: Added warning about invalid register specification for local variables. llvm-svn: 123236 --- clang/lib/Sema/SemaDecl.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') 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(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)); } -- cgit v1.2.3