From e6563256a4b3b9fee70ce3335d28406607c1faaf Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 13 Jun 2010 05:34:18 +0000 Subject: [PATCH] Allow an asm label specifier on C++ methods, like GCC does. Patch by David Majnemer! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105909 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseDeclCXX.cpp | 13 +++++++++++-- test/Parser/cxx-decl.cpp | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index eda490d918..9cf025df5e 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1373,7 +1373,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // declarator pure-specifier[opt] // declarator constant-initializer[opt] // identifier[opt] ':' constant-expression - if (Tok.is(tok::colon)) { ConsumeToken(); BitfieldSize = ParseConstantExpression(); @@ -1390,7 +1389,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // defaulted/deleted function-definition: // '=' 'default' [TODO] // '=' 'delete' - if (Tok.is(tok::equal)) { ConsumeToken(); if (getLang().CPlusPlus0x && Tok.is(tok::kw_delete)) { @@ -1403,6 +1401,17 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } } + // If a simple-asm-expr is present, parse it. + if (Tok.is(tok::kw_asm)) { + SourceLocation Loc; + OwningExprResult AsmLabel(ParseSimpleAsm(&Loc)); + if (AsmLabel.isInvalid()) + SkipUntil(tok::comma, true, true); + + DeclaratorInfo.setAsmLabel(AsmLabel.release()); + DeclaratorInfo.SetRangeEnd(Loc); + } + // If attributes exist after the declarator, parse them. if (Tok.is(tok::kw___attribute)) { SourceLocation Loc; diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index ae004ce81c..e4c703c334 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -37,6 +37,10 @@ class someclass { } }; +class asm_class_test { + void foo() __asm__("baz"); +}; + enum { fooenum = 1 }; struct a { -- 2.40.0