]> granicus.if.org Git - clang/commitdiff
fix PR5500: clang fails to parse inline asm with :: in C++ mode
authorChris Lattner <sabre@nondot.org>
Sun, 20 Dec 2009 23:08:04 +0000 (23:08 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 20 Dec 2009 23:08:04 +0000 (23:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91802 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmt.cpp
test/Parser/cxx-stmt.cpp

index c3595b9e132dc64efb826cbe3ad6ef1512185458..9085b8713dfdc6b595196bfc997c13df914e4de1 100644 (file)
@@ -1259,18 +1259,32 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
   }
 
   // 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 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
   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) {
index 3fd3e256a877df1488c9a08f03ee930b5c086eaa..fdd573e6bfa5de2769935f697a7bf5655a7e0057 100644 (file)
@@ -52,3 +52,9 @@ void f4() {
     case Type: i = 7; break;  // no error.
   }
 }
+
+// PR5500
+void f5() {
+  asm volatile ("":: :"memory");
+  asm volatile ("": ::"memory");
+}