]> granicus.if.org Git - clang/commitdiff
Allow an asm label specifier on C++ methods, like GCC does.
authorChris Lattner <sabre@nondot.org>
Sun, 13 Jun 2010 05:34:18 +0000 (05:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 13 Jun 2010 05:34:18 +0000 (05:34 +0000)
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
test/Parser/cxx-decl.cpp

index eda490d918cff9f029a34bde6cb2d7b0bfbd23cf..9cf025df5eda05a0c125a2f053aac986e3b217e9 100644 (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;
index ae004ce81c1d5347075d7b405ca247ec00626129..e4c703c334bd12552ff0831ae6004f8e3977b788 100644 (file)
@@ -37,6 +37,10 @@ class someclass {
   }
 };
 
+class asm_class_test {
+  void foo() __asm__("baz");
+};
+
 enum { fooenum = 1 };
 
 struct a {