aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-18 06:06:23 +0000
committerChris Lattner <sabre@nondot.org>2007-12-18 06:06:23 +0000
commitd7d860d97acf25b683756c0c5c3ee33b0f0a731d (patch)
treea1b9f3983940fe4f3ea8d173faa59bbebd4d5a8e
parent1ca9b11b3114a618c360749a2f202fad29705bd9 (diff)
Fix an nice and subtle parser bug reported by Nico Weber.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45149 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Parse/ParseExpr.cpp4
-rw-r--r--test/Sema/conditional.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/Parse/ParseExpr.cpp b/Parse/ParseExpr.cpp
index c1a200cd71..0a1af1b1a7 100644
--- a/Parse/ParseExpr.cpp
+++ b/Parse/ParseExpr.cpp
@@ -364,8 +364,8 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) {
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.
diff --git a/test/Sema/conditional.c b/test/Sema/conditional.c
new file mode 100644
index 0000000000..3af0fe57b4
--- /dev/null
+++ b/test/Sema/conditional.c
@@ -0,0 +1,4 @@
+// RUN: clang %s -fsyntax-only
+
+const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
+