[cfe-commits] r91039 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Parser/cxx-decl.cpp
Chris Lattner
sabre at nondot.org
Wed Dec 9 18:02:58 PST 2009
Author: lattner
Date: Wed Dec 9 20:02:58 2009
New Revision: 91039
URL: http://llvm.org/viewvc/llvm-project?rev=91039&view=rev
Log:
fix a more evil case of : / :: confusion arising in ?:.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/Parser/cxx-decl.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=91039&r1=91038&r2=91039&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Dec 9 20:02:58 2009
@@ -317,6 +317,9 @@
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
Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=91039&r1=91038&r2=91039&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Wed Dec 9 20:02:58 2009
@@ -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 @@
int Type : fooenum;
};
+void test(struct Type *P) {
+ int Type;
+ Type = 1 ? P->Type : Type;
+}
\ No newline at end of file
More information about the cfe-commits
mailing list