aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2025-11-22 19:10:40 +0100
committer lemon<lsof@mailbox.org>2025-11-22 19:10:40 +0100
commit8cf560c502542af972eabd201a5b7bf05c891078 (patch)
tree9053784cb481dea65be9930a64e54f1f624ecfbd
parent2f2df5093b5e02b2cc2ad05894dc3cbb4e6fac0c (diff)
c: fix precedence of conditional expression rhs
-rw-r--r--c/c.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/c/c.c b/c/c.c
index b6ca90e..05308e1 100644
--- a/c/c.c
+++ b/c/c.c
@@ -1080,7 +1080,7 @@ Unary:
assert(ty.t);
ex = mkexpr(ek, span, ty, .sub = exprdup2(cm, &ex, &rhs));
} else {
- /* ex ? tmp : rhs */
+ /* logical-OR-expression ? expression : conditional-expression */
struct expr *sub;
span.sl = tk.span.sl;
span.ex = ex.span.ex;
@@ -1089,7 +1089,7 @@ Unary:
tmp = commaexpr(cm);
joinspan(&tk.span.ex, tmp.span.ex);
expect(cm, ':', NULL);
- rhs = expr(cm);
+ rhs = exprparse(cm, opprec, NULL, 0);
if (!joinspan(&span.ex, tk.span.ex) || !joinspan(&span.ex, tmp.span.ex)
|| !joinspan(&span.ex, rhs.span.ex))
span.ex = tk.span.ex;