aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Parse/ParseExpr.cpp3
-rw-r--r--test/Parser/cxx-decl.cpp8
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 54131e0ccc..2536cee1cb 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -317,6 +317,9 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) {
OwningExprResult TernaryMiddle(Actions, true);
if (NextTokPrec == prec::Conditional) {
if (Tok.isNot(tok::colon)) {
+ // Don't parse FOO:BAR as if it were a typo for FOO::BAR.
+ ColonProtectionRAIIObject X(*this);
+
// Handle this production specially:
// logical-OR-expression '?' expression ':' conditional-expression
// In particular, the RHS of the '?' is 'expression', not
diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp
index 4453c4c3d0..38467117b3 100644
--- a/test/Parser/cxx-decl.cpp
+++ b/test/Parser/cxx-decl.cpp
@@ -2,7 +2,9 @@
int x(*g); // expected-error {{use of undeclared identifier 'g'}}
-struct Type { };
+struct Type {
+ int Type;
+};
// PR4451 - We should recover well from the typo of '::' as ':' in a2.
@@ -40,3 +42,7 @@ struct a {
int Type : fooenum;
};
+void test(struct Type *P) {
+ int Type;
+ Type = 1 ? P->Type : Type;
+} \ No newline at end of file