commit 1ea6db00892dda7ca552d604e1cf58b1be63a683 parent 3f79201def3efe20717a163fee4ca0142a4f0dbd Author: Ryan Sepassi <rsepassi@gmail.com> Date: Tue, 19 May 2026 14:11:37 -0700 test: add red C11 frontend coverage Diffstat:
29 files changed, 151 insertions(+), 0 deletions(-)
diff --git a/test/parse/CORPUS.md b/test/parse/CORPUS.md @@ -194,6 +194,9 @@ here for completeness once they're real cases. | `6_5_57_unsigned_wrap_add` | ★ | `unsigned x=0xFFFFFFFFU; x+=1; return (int)(x & 0xff);` — unsigned addition wraps modulo 2^32 | 0 | | `6_5_58_large_integer_immediates` | ★ | 64-bit boundary integer literals including `INT64_MAX`, top-bit unsigned, and all-ones materialize correctly | 42 | | `6_5_65_file_scope_compound_literal` | RED | `static int *p = (int[]){42}; return p[0];` — file-scope compound literal has static storage duration | 42 | +| `6_5_2_5_01_compound_literal_flat_struct` | RED | `(struct O){1,2,39}` initializes nested struct members without inner braces | 42 | +| `6_5_2_5_02_compound_literal_designated_continue` | RED | `(struct S){.a[1]=20,22,0}` continues from the next subobject after a designator | 42 | +| `6_5_3_4_04_sizeof_vla_param_row` | RED | `sizeof(a[0])` where `a` is an adjusted `int a[n][m]` parameter is evaluated at runtime | 42 | ## §6.5.2.2 Aggregate function arguments @@ -360,6 +363,8 @@ already exercised in §6.5 and §6.7. | `6_7_6_13_star_in_proto` | ★ | `int total(int n, int a[*]); int total(int n, int a[n]){...}` — `[*]` in non-definition prototype | 42 | | `6_7_6_14_func_param_adjust` | ★ | `int apply(int f(int), int x){return f(x);}` — function parameter adjusted to pointer-to-function | 42 | | `6_7_6_15_multidim_vla_local` | RED | `int a[n][m]; a[n-1][m-1]=42; return a[5][6];` — multiple VLA dimensions in one declarator | 42 | +| `6_7_6_16_vla_param_2d` | RED | `int a[n][m]` parameter passed a 2D array; runtime stride must use `m` | 42 | +| `6_7_6_17_vla_param_3d` | RED | `int a[n][m][k]` parameter passed a 3D array; nested runtime strides must compose | 42 | ## §6.7.7 Type names @@ -408,6 +413,12 @@ cover compound typedef targets. | `6_7_9_21_array_of_struct_size_from_init` | ★ | `static const S t[] = { {10,12}, {7,13} };` — file-scope incomplete-array-of-struct sized from init list | 44 | | `6_7_9_22_static_union_designated_nonfirst` | ★ | `static union U{int a; int b;} g={.b=42}; return g.b;` — static-storage union designated init | 42 | | `6_7_9_23_static_ptr_null_const_expr` | ★ | `static int* p = 1 - 1; return p == 0 ? 42 : 0;` — null pointer constant via integer constant expression | 42 | +| `6_7_9_24_flat_array_init` | RED | `int a[2][2] = {1,2,3,36};` — braces may be elided for nested array initialization | 42 | +| `6_7_9_25_flat_struct_init` | RED | `struct O o = {1,2,39};` — braces may be elided for nested struct initialization | 42 | +| `6_7_9_26_designated_continue_subobject` | RED | `struct S s = {.a[1]=20,22,0};` — initializer continues after the designated subobject | 42 | +| `6_7_9_27_static_flat_array_init` | RED | file-scope `static int a[2][2] = {1,2,3,36};` | 42 | +| `6_7_9_28_static_flat_struct_init` | RED | file-scope `static struct O o = {1,2,39};` | 42 | +| `6_7_9_29_unknown_bound_nested_init` | RED | `int a[][2] = {1,2,3,36};` — unknown outer bound is completed from a flat nested initializer | 42 | ## §6.7.10 Static assertions @@ -480,6 +491,9 @@ memcpys into before `ret`. | `6_9_11_tentative_multi` | ★ | full TU: `int g; int g;` — two tentative defs merge; `return g+42` | 42 | | `6_9_12_tentative_incomplete_array` | ★ | full TU: `int arr[]; int arr[3];` — tentative + completing decl; `return arr[0]+arr[1]+arr[2]+42` | 42 | | `6_9_13_extern_func_def` | ★ | full TU: `extern int helper(int x){return x+1;}` — extern on a definition; `helper(41)` | 42 | +| `6_9_14_kr_function_def_params` | RED | old-style function definition with declaration-list `int add(a,b) int a; int b;` | 42 | +| `6_9_15_kr_function_def_promoted_char` | RED | old-style definition with promoted `char` parameter declaration | 42 | +| `6_9_16_block_scope_func_decl` | RED | block-scope `int helper(void);` has external linkage and calls the later file-scope definition | 42 | ## Builtins diff --git a/test/parse/cases/6_5_2_5_01_compound_literal_flat_struct.c b/test/parse/cases/6_5_2_5_01_compound_literal_flat_struct.c @@ -0,0 +1,14 @@ +struct I { + int a; + int b; +}; + +struct O { + struct I i; + int c; +}; + +int test_main(void) { + struct O o = (struct O){1, 2, 39}; + return o.i.a + o.i.b + o.c; +} diff --git a/test/parse/cases/6_5_2_5_01_compound_literal_flat_struct.expected b/test/parse/cases/6_5_2_5_01_compound_literal_flat_struct.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_5_2_5_02_compound_literal_designated_continue.c b/test/parse/cases/6_5_2_5_02_compound_literal_designated_continue.c @@ -0,0 +1,9 @@ +struct S { + int a[3]; + int b; +}; + +int test_main(void) { + struct S s = (struct S){.a[1] = 20, 22, 0}; + return s.a[1] + s.a[2] + s.b; +} diff --git a/test/parse/cases/6_5_2_5_02_compound_literal_designated_continue.expected b/test/parse/cases/6_5_2_5_02_compound_literal_designated_continue.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_5_3_4_04_sizeof_vla_param_row.c b/test/parse/cases/6_5_3_4_04_sizeof_vla_param_row.c @@ -0,0 +1,9 @@ +int row_size(int n, int m, int a[n][m]) { + (void)n; + return (int)sizeof(a[0]); +} + +int test_main(void) { + int a[2][6]; + return row_size(2, 6, a) + 18; +} diff --git a/test/parse/cases/6_5_3_4_04_sizeof_vla_param_row.expected b/test/parse/cases/6_5_3_4_04_sizeof_vla_param_row.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_6_16_vla_param_2d.c b/test/parse/cases/6_7_6_16_vla_param_2d.c @@ -0,0 +1,8 @@ +int pick_last(int n, int m, int a[n][m]) { + return a[n - 1][m - 1]; +} + +int test_main(void) { + int a[2][3] = {{0, 0, 0}, {0, 0, 42}}; + return pick_last(2, 3, a); +} diff --git a/test/parse/cases/6_7_6_16_vla_param_2d.expected b/test/parse/cases/6_7_6_16_vla_param_2d.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_6_17_vla_param_3d.c b/test/parse/cases/6_7_6_17_vla_param_3d.c @@ -0,0 +1,8 @@ +int pick_last(int n, int m, int k, int a[n][m][k]) { + return a[n - 1][m - 1][k - 1]; +} + +int test_main(void) { + int a[2][2][2] = {{{0, 0}, {0, 0}}, {{0, 0}, {0, 42}}}; + return pick_last(2, 2, 2, a); +} diff --git a/test/parse/cases/6_7_6_17_vla_param_3d.expected b/test/parse/cases/6_7_6_17_vla_param_3d.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_9_24_flat_array_init.c b/test/parse/cases/6_7_9_24_flat_array_init.c @@ -0,0 +1,4 @@ +int test_main(void) { + int a[2][2] = {1, 2, 3, 36}; + return a[0][0] + a[0][1] + a[1][0] + a[1][1]; +} diff --git a/test/parse/cases/6_7_9_24_flat_array_init.expected b/test/parse/cases/6_7_9_24_flat_array_init.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_9_25_flat_struct_init.c b/test/parse/cases/6_7_9_25_flat_struct_init.c @@ -0,0 +1,12 @@ +int test_main(void) { + struct I { + int a; + int b; + }; + struct O { + struct I i; + int c; + }; + struct O o = {1, 2, 39}; + return o.i.a + o.i.b + o.c; +} diff --git a/test/parse/cases/6_7_9_25_flat_struct_init.expected b/test/parse/cases/6_7_9_25_flat_struct_init.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_9_26_designated_continue_subobject.c b/test/parse/cases/6_7_9_26_designated_continue_subobject.c @@ -0,0 +1,8 @@ +int test_main(void) { + struct S { + int a[3]; + int b; + }; + struct S s = {.a[1] = 20, 22, 0}; + return s.a[1] + s.a[2] + s.b; +} diff --git a/test/parse/cases/6_7_9_26_designated_continue_subobject.expected b/test/parse/cases/6_7_9_26_designated_continue_subobject.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_9_27_static_flat_array_init.c b/test/parse/cases/6_7_9_27_static_flat_array_init.c @@ -0,0 +1,5 @@ +static int a[2][2] = {1, 2, 3, 36}; + +int test_main(void) { + return a[0][0] + a[0][1] + a[1][0] + a[1][1]; +} diff --git a/test/parse/cases/6_7_9_27_static_flat_array_init.expected b/test/parse/cases/6_7_9_27_static_flat_array_init.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_9_28_static_flat_struct_init.c b/test/parse/cases/6_7_9_28_static_flat_struct_init.c @@ -0,0 +1,15 @@ +struct I { + int a; + int b; +}; + +struct O { + struct I i; + int c; +}; + +static struct O o = {1, 2, 39}; + +int test_main(void) { + return o.i.a + o.i.b + o.c; +} diff --git a/test/parse/cases/6_7_9_28_static_flat_struct_init.expected b/test/parse/cases/6_7_9_28_static_flat_struct_init.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_7_9_29_unknown_bound_nested_init.c b/test/parse/cases/6_7_9_29_unknown_bound_nested_init.c @@ -0,0 +1,4 @@ +int test_main(void) { + int a[][2] = {1, 2, 3, 36}; + return a[0][0] + a[0][1] + a[1][0] + a[1][1]; +} diff --git a/test/parse/cases/6_7_9_29_unknown_bound_nested_init.expected b/test/parse/cases/6_7_9_29_unknown_bound_nested_init.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_9_14_kr_function_def_params.c b/test/parse/cases/6_9_14_kr_function_def_params.c @@ -0,0 +1,10 @@ +int add(a, b) +int a; +int b; +{ + return a + b; +} + +int test_main(void) { + return add(20, 22); +} diff --git a/test/parse/cases/6_9_14_kr_function_def_params.expected b/test/parse/cases/6_9_14_kr_function_def_params.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_9_15_kr_function_def_promoted_char.c b/test/parse/cases/6_9_15_kr_function_def_promoted_char.c @@ -0,0 +1,9 @@ +int id_char(c) +char c; +{ + return c; +} + +int test_main(void) { + return id_char(42); +} diff --git a/test/parse/cases/6_9_15_kr_function_def_promoted_char.expected b/test/parse/cases/6_9_15_kr_function_def_promoted_char.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases/6_9_16_block_scope_func_decl.c b/test/parse/cases/6_9_16_block_scope_func_decl.c @@ -0,0 +1,8 @@ +int test_main(void) { + int helper(void); + return helper(); +} + +int helper(void) { + return 42; +} diff --git a/test/parse/cases/6_9_16_block_scope_func_decl.expected b/test/parse/cases/6_9_16_block_scope_func_decl.expected @@ -0,0 +1 @@ +42