]> granicus.if.org Git - clang/commitdiff
Fix PR7673 by allowing an empty clobbers section in an ASM statement.
authorChandler Carruth <chandlerc@gmail.com>
Thu, 22 Jul 2010 07:11:21 +0000 (07:11 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 22 Jul 2010 07:11:21 +0000 (07:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109087 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmt.cpp
test/Parser/asm.c

index c908ed9caec69f82a92b5c1e76e7f874efc62ff0..baf8488e74106fb3cdebb6e691b06be832cd1cd3 100644 (file)
@@ -1367,17 +1367,19 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
     if (!AteExtraColon)
       ConsumeToken();
 
-    // Parse the asm-string list for clobbers.
-    while (1) {
-      OwningExprResult Clobber(ParseAsmStringLiteral());
+    // Parse the asm-string list for clobbers if present.
+    if (Tok.isNot(tok::r_paren)) {
+      while (1) {
+        OwningExprResult Clobber(ParseAsmStringLiteral());
 
-      if (Clobber.isInvalid())
-        break;
+        if (Clobber.isInvalid())
+          break;
 
-      Clobbers.push_back(Clobber.release());
+        Clobbers.push_back(Clobber.release());
 
-      if (Tok.isNot(tok::comma)) break;
-      ConsumeToken();
+        if (Tok.isNot(tok::comma)) break;
+        ConsumeToken();
+      }
     }
   }
 
index df2e16feea5bc78706cb5ba3ab926fb8fcba07f0..90818261513fe3a2290af3202b90d42f83036faf 100644 (file)
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 void f1() {
-  asm ("ret" : : :); // expected-error {{expected string literal}}
+  // PR7673: Some versions of GCC support an empty clobbers section.
+  asm ("ret" : : :);
 }
 
 void f2() {