commit a61591aadc232259653aa21c4836012b7f06a380
parent 4159f6046e8f38de576b2c260d63757a0c9a2a8b
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Sun, 26 Apr 2026 22:47:36 -0700
cc tests: enum constant in expressions (§K.3)
Locks in parse-primary's enum-const branch: `enum E { A=1, B=10, C };`
makes A/B/C visible in scope as enum-const syms; the parser pushes
their integer value as an imm rval. C without explicit init takes
the previous + 1 (here: 11).
Diffstat:
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tests/cc-parse/72-enum-const.c b/tests/cc-parse/72-enum-const.c
@@ -0,0 +1,6 @@
+/* §K.3 — enum constants in expressions. */
+enum E { A = 1, B = 10, C }; /* C defaults to 11 */
+
+int main(void) {
+ return A + B + C; /* 1 + 10 + 11 = 22 */
+}
diff --git a/tests/cc-parse/72-enum-const.expected-exit b/tests/cc-parse/72-enum-const.expected-exit
@@ -0,0 +1 @@
+22