Allow an asm label specifier on C++ methods, like GCC does.

Patch by David Majnemer!

llvm-svn: 105909
This commit is contained in:
Chris Lattner
2010-06-13 05:34:18 +00:00
parent d773fe67dd
commit f3d3b36870
2 changed files with 15 additions and 2 deletions

View File

@@ -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;

View File

@@ -37,6 +37,10 @@ class someclass {
}
};
class asm_class_test {
void foo() __asm__("baz");
};
enum { fooenum = 1 };
struct a {