summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Parse/Parser.cpp11
-rw-r--r--clang/test/Parser/asm.c13
2 files changed, 18 insertions, 6 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 66ed352ef68..310105a4ac6 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1354,16 +1354,15 @@ Parser::ExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) {
ExprResult Result(ParseAsmStringLiteral());
- if (Result.isInvalid()) {
- SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch);
- if (EndLoc)
- *EndLoc = Tok.getLocation();
- ConsumeAnyToken();
- } else {
+ if (!Result.isInvalid()) {
// Close the paren and get the location of the end bracket
T.consumeClose();
if (EndLoc)
*EndLoc = T.getCloseLocation();
+ } else if (SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch)) {
+ if (EndLoc)
+ *EndLoc = Tok.getLocation();
+ ConsumeParen();
}
return Result;
diff --git a/clang/test/Parser/asm.c b/clang/test/Parser/asm.c
index b95e08bcca1..dabb010529a 100644
--- a/clang/test/Parser/asm.c
+++ b/clang/test/Parser/asm.c
@@ -23,3 +23,16 @@ __asm ; // expected-error {{expected '(' after 'asm'}}
// <rdar://problem/10465079> - Don't crash on wide string literals in 'asm'.
int foo asm (L"bar"); // expected-error {{cannot use wide string literal in 'asm'}}
+asm() // expected-error {{expected string literal in 'asm'}}
+// expected-error@-1 {{expected ';' after top-level asm block}}
+
+asm(; // expected-error {{expected string literal in 'asm'}}
+
+asm("") // expected-error {{expected ';' after top-level asm block}}
+
+// Unterminated asm strings at the end of the file were causing us to crash, so
+// this needs to be last. rdar://15624081
+// expected-warning@+3 {{missing terminating '"' character}}
+// expected-error@+2 {{expected string literal in 'asm'}}
+// expected-error@+1 {{expected ';' after top-level asm block}}
+asm("
OpenPOWER on IntegriCloud