diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-08-05 01:35:17 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-05 01:35:17 +0000 |
commit | a80f8749f2968d19595ca2544114932bf0ca2c11 (patch) | |
tree | fb1a27a8795fa3ac5c6b965cf38d1be74bfe49dc /lib/Sema/SemaDecl.cpp | |
parent | 820b03398fdcc8f1f6c60ace55b708e311fa8ce4 (diff) |
Add more Parser/Sema support for GCC asm-label extension.
- ActOnDeclarator now takes an additional parameter which is the
AsmLabel if used. Its unfortunate that this bubbles up this high,
but we cannot just lump it in as an attribute without mistakenly
*accepting* it as an attribute.
- The actual asm-label itself is, however, encoded as an AsmLabelAttr
on the FunctionDecl.
- Slightly improved parser error recovery on malformed asm-labels.
- CodeGen support still missing...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index e9343e3989..64e62369e7 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -609,7 +609,7 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType) { } Sema::DeclTy * -Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { +Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl, ExprTy *AsmLabel) { ScopedDecl *LastDeclarator = dyn_cast_or_null<ScopedDecl>((Decl *)lastDecl); IdentifierInfo *II = D.getIdentifier(); @@ -700,6 +700,14 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { // Handle attributes. ProcessDeclAttributes(NewFD, D); + // Handle GNU asm-label extension (encoded as an attribute). + if (Expr *E = (Expr*) AsmLabel) { + // The parser guarantees this is a string. + StringLiteral *SE = cast<StringLiteral>(E); + NewFD->addAttr(new AsmLabelAttr(std::string(SE->getStrData(), + SE->getByteLength()))); + } + // Copy the parameter declarations from the declarator D to // the function declaration NewFD, if they are available. if (D.getNumTypeObjects() > 0 && @@ -1569,7 +1577,7 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) { } return ActOnStartOfFunctionDef(FnBodyScope, - ActOnDeclarator(GlobalScope, D, 0)); + ActOnDeclarator(GlobalScope, D, 0, 0)); } Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) { @@ -1661,7 +1669,7 @@ ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, CurContext = Context.getTranslationUnitDecl(); FunctionDecl *FD = - dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0))); + dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0, 0))); FD->setImplicit(); CurContext = PrevDC; |