]> granicus.if.org Git - clang/commitdiff
fix a more evil case of : / :: confusion arising in ?:.
authorChris Lattner <sabre@nondot.org>
Thu, 10 Dec 2009 02:02:58 +0000 (02:02 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 10 Dec 2009 02:02:58 +0000 (02:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91039 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/Parser/cxx-decl.cpp

index 54131e0ccc5065ed487d0a1ce52627a6fd94b0e7..2536cee1cbdbcee3e28e678630fea01704ac1701 100644 (file)
@@ -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
index 4453c4c3d0d23187dc97d5eb0155c79cabafabb0..38467117b340bc31a7052fe97ab55945ccedc522 100644 (file)
@@ -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