aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-20 23:08:04 +0000
committerChris Lattner <sabre@nondot.org>2009-12-20 23:08:04 +0000
commit6405646cb649e4b4c6768b92d1fc83c175722f62 (patch)
tree964cd6ad8ae5046fc5a2e06155cb82288068e5a8 /lib/Parse/ParseStmt.cpp
parent64cb4757acbf10f0c702f17c4fe90f4b7aba3490 (diff)
fix PR5500: clang fails to parse inline asm with :: in C++ mode
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index c3595b9e13..9085b8713d 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -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) {