If we enter parens, colons can become un-sacred, allowing us to emit
a better diagnostic in the second example.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91040 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 2536cee..bdbc67f 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -565,9 +565,15 @@
     TypeTy *CastTy;
     SourceLocation LParenLoc = Tok.getLocation();
     SourceLocation RParenLoc;
-    Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
-                               TypeOfCast, CastTy, RParenLoc);
-    if (Res.isInvalid()) return move(Res);
+    
+    {
+      // The inside of the parens don't need to be a colon protected scope.
+      ColonProtectionRAIIObject X(*this, false);
+    
+      Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
+                                 TypeOfCast, CastTy, RParenLoc);
+      if (Res.isInvalid()) return move(Res);
+    }
 
     switch (ParenExprType) {
     case SimpleExpr:   break;    // Nothing else to do.
diff --git a/lib/Parse/RAIIObjectsForParser.h b/lib/Parse/RAIIObjectsForParser.h
index 93b9a82..d048f04 100644
--- a/lib/Parse/RAIIObjectsForParser.h
+++ b/lib/Parse/RAIIObjectsForParser.h
@@ -48,8 +48,9 @@
     Parser &P;
     bool OldVal;
   public:
-    ColonProtectionRAIIObject(Parser &p) : P(p), OldVal(P.ColonIsSacred) {
-      P.ColonIsSacred = true;
+    ColonProtectionRAIIObject(Parser &p, bool Value = true)
+      : P(p), OldVal(P.ColonIsSacred) {
+      P.ColonIsSacred = Value;
     }
     
     /// restore - This can be used to restore the state early, before the dtor