[cfe-commits] r91802 - in /cfe/trunk: lib/Parse/ParseStmt.cpp test/Parser/cxx-stmt.cpp

Chris Lattner sabre at nondot.org
Sun Dec 20 15:08:04 PST 2009


Author: lattner
Date: Sun Dec 20 17:08:04 2009
New Revision: 91802

URL: http://llvm.org/viewvc/llvm-project?rev=91802&view=rev
Log:
fix PR5500: clang fails to parse inline asm with :: in C++ mode 

Modified:
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/test/Parser/cxx-stmt.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=91802&r1=91801&r2=91802&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Sun Dec 20 17:08:04 2009
@@ -1259,18 +1259,32 @@
   }
 
   // Parse Outputs, if present.
-  if (Tok.is(tok::colon)) {
+  bool AteExtraColon = false;
+  if (Tok.is(tok::colon) || Tok.is(tok::coloncolon)) {
+    // In C++ mode, parse "::" like ": :".
+    AteExtraColon = Tok.is(tok::coloncolon);
     ConsumeToken();
   
-    if (ParseAsmOperandsOpt(Names, Constraints, Exprs))
+    if (!AteExtraColon &&
+        ParseAsmOperandsOpt(Names, Constraints, Exprs))
       return StmtError();
   }
+  
   unsigned NumOutputs = Names.size();
 
   // Parse Inputs, if present.
-  if (Tok.is(tok::colon)) {
-    ConsumeToken();
-    if (ParseAsmOperandsOpt(Names, Constraints, Exprs))
+  if (AteExtraColon ||
+      Tok.is(tok::colon) || Tok.is(tok::coloncolon)) {
+    // In C++ mode, parse "::" like ": :".
+    if (AteExtraColon)
+      AteExtraColon = false;
+    else {
+      AteExtraColon = Tok.is(tok::coloncolon);
+      ConsumeToken();
+    }
+    
+    if (!AteExtraColon &&
+        ParseAsmOperandsOpt(Names, Constraints, Exprs))
       return StmtError();
   }
 
@@ -1281,8 +1295,9 @@
   unsigned NumInputs = Names.size() - NumOutputs;
 
   // Parse the clobbers, if present.
-  if (Tok.is(tok::colon)) {
-    ConsumeToken();
+  if (AteExtraColon || Tok.is(tok::colon)) {
+    if (!AteExtraColon)
+      ConsumeToken();
 
     // Parse the asm-string list for clobbers.
     while (1) {

Modified: cfe/trunk/test/Parser/cxx-stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-stmt.cpp?rev=91802&r1=91801&r2=91802&view=diff

==============================================================================
--- cfe/trunk/test/Parser/cxx-stmt.cpp (original)
+++ cfe/trunk/test/Parser/cxx-stmt.cpp Sun Dec 20 17:08:04 2009
@@ -52,3 +52,9 @@
     case Type: i = 7; break;  // no error.
   }
 }
+
+// PR5500
+void f5() {
+  asm volatile ("":: :"memory");
+  asm volatile ("": ::"memory");
+}





More information about the cfe-commits mailing list