[cfe-commits] r45149 - in /cfe/trunk: Parse/ParseExpr.cpp test/Sema/conditional.c

Chris Lattner sabre at nondot.org
Mon Dec 17 22:06:24 PST 2007


Author: lattner
Date: Tue Dec 18 00:06:23 2007
New Revision: 45149

URL: http://llvm.org/viewvc/llvm-project?rev=45149&view=rev
Log:
Fix an nice and subtle parser bug reported by Nico Weber.

Added:
    cfe/trunk/test/Sema/conditional.c
Modified:
    cfe/trunk/Parse/ParseExpr.cpp

Modified: cfe/trunk/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseExpr.cpp?rev=45149&r1=45148&r2=45149&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/Parse/ParseExpr.cpp Tue Dec 18 00:06:23 2007
@@ -364,8 +364,8 @@
     NextTokPrec = getBinOpPrecedence(Tok.getKind());
 
     // Assignment and conditional expressions are right-associative.
-    bool isRightAssoc = NextTokPrec == prec::Conditional ||
-                        NextTokPrec == prec::Assignment;
+    bool isRightAssoc = ThisPrec == prec::Conditional ||
+                        ThisPrec == prec::Assignment;
 
     // Get the precedence of the operator to the right of the RHS.  If it binds
     // more tightly with RHS than we do, evaluate it completely first.

Added: cfe/trunk/test/Sema/conditional.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conditional.c?rev=45149&view=auto

==============================================================================
--- cfe/trunk/test/Sema/conditional.c (added)
+++ cfe/trunk/test/Sema/conditional.c Tue Dec 18 00:06:23 2007
@@ -0,0 +1,4 @@
+// RUN: clang %s -fsyntax-only
+
+const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
+





More information about the cfe-commits mailing list