summaryrefslogtreecommitdiffstats
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
commitdcb7cc59aec5d5bc8e210afedb0cba458e56bae9 (patch)
tree62efa6f2eb83a4e1e17a697036affc962bd3612e
parentb723564c793a7650256042ec9347d2a8b0f56846 (diff)
downloadbcm5719-llvm-dcb7cc59aec5d5bc8e210afedb0cba458e56bae9.tar.gz
bcm5719-llvm-dcb7cc59aec5d5bc8e210afedb0cba458e56bae9.zip
Fix an nice and subtle parser bug reported by Nico Weber.
llvm-svn: 45149
-rw-r--r--clang/Parse/ParseExpr.cpp4
-rw-r--r--clang/test/Sema/conditional.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/Parse/ParseExpr.cpp b/clang/Parse/ParseExpr.cpp
index c1a200cd710..0a1af1b1a7d 100644
--- a/clang/Parse/ParseExpr.cpp
+++ b/clang/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/clang/test/Sema/conditional.c b/clang/test/Sema/conditional.c
new file mode 100644
index 00000000000..3af0fe57b43
--- /dev/null
+++ b/clang/test/Sema/conditional.c
@@ -0,0 +1,4 @@
+// RUN: clang %s -fsyntax-only
+
+const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
+
OpenPOWER on IntegriCloud