From: Chandler Carruth Date: Thu, 22 Jul 2010 07:11:21 +0000 (+0000) Subject: Fix PR7673 by allowing an empty clobbers section in an ASM statement. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=102e1b6a4753b0bd3662ad1bd119f6efa04b8763;p=clang Fix PR7673 by allowing an empty clobbers section in an ASM statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109087 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index c908ed9cae..baf8488e74 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -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(); + } } } diff --git a/test/Parser/asm.c b/test/Parser/asm.c index df2e16feea..9081826151 100644 --- a/test/Parser/asm.c +++ b/test/Parser/asm.c @@ -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() {