kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit fb02a54edf304b1e8cad51f7985b123e1e809e2e
parent efce37cf44757ee952a79b3d98f42096b6c1b65a
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Mon, 18 May 2026 14:50:17 -0700

test: expand C11 conformance gap coverage

Diffstat:
Mdoc/C11_CONFORMANCE_CHECKLIST.md | 43++++++++++++++++++++++++++++++++++++++++++-
Mtest/parse/CORPUS.md | 61+++++++++++++++++++++++++++++++++++++++++++------------------
Atest/parse/cases/6_7_6_14_func_param_adjust.c | 9+++++++++
Atest/parse/cases/6_7_6_14_func_param_adjust.expected | 1+
Atest/parse/cases_err/6_5_addr_of_bitfield.c | 5+++++
Atest/parse/cases_err/6_5_cast_scalar_from_struct.c | 4++++
Atest/parse/cases_err/6_5_cond_incompatible_ptr.c | 6++++++
Atest/parse/cases_err/6_5_lvalue_array_assign.c | 6++++++
Atest/parse/cases_err/6_5_pointer_add_pointer.c | 6++++++
Atest/parse/cases_err/6_5_rel_incompatible_ptr.c | 5+++++
Atest/parse/cases_err/6_5_scalar_required_if.c | 5+++++
Atest/parse/cases_err/6_5_sizeof_bitfield.c | 4++++
Atest/parse/cases_err/6_5_sizeof_function.c | 5+++++
Atest/parse/cases_err/6_6_static_init_nonconstant.c | 6++++++
Atest/parse/cases_err/6_7_2_1_bitfield_bad_type.c | 7+++++++
Atest/parse/cases_err/6_7_2_1_bitfield_named_zero_width.c | 7+++++++
Atest/parse/cases_err/6_7_2_1_bitfield_negative_width.c | 7+++++++
Atest/parse/cases_err/6_7_2_1_bitfield_nonconstant_width.c | 5+++++
Atest/parse/cases_err/6_7_2_tag_wrong_kind.c | 6++++++
Atest/parse/cases_err/6_7_6_function_returning_array.c | 5+++++
Atest/parse/cases_err/6_7_6_function_returning_function.c | 5+++++
Atest/parse/cases_err/6_7_6_variadic_not_last.c | 5+++++
Atest/parse/cases_err/6_7_9_excess_scalar_init.c | 4++++
Atest/parse/cases_err/6_7_9_invalid_array_designator.c | 5+++++
Atest/parse/cases_err/6_7_9_invalid_struct_designator.c | 4++++
Atest/parse/cases_err/6_7_9_invalid_union_designator.c | 4++++
26 files changed, 211 insertions(+), 19 deletions(-)

diff --git a/doc/C11_CONFORMANCE_CHECKLIST.md b/doc/C11_CONFORMANCE_CHECKLIST.md @@ -10,7 +10,12 @@ make the implementation pass it. - [x] `make test-lex` passes: 16/16. - [x] `make test-pp test-pp-err` passes: 82/82 and 15/15. -- [x] `make test-parse-err` passes: 30/30. +- [ ] `make test-parse-err` passes with expanded C11 constraint coverage: + currently 48/56 pass, 8 fail. Current red cases are + `6_5_addr_of_bitfield`, `6_5_cast_scalar_from_struct`, + `6_5_cond_incompatible_ptr`, `6_5_pointer_add_pointer`, + `6_5_rel_incompatible_ptr`, `6_5_scalar_required_if`, + `6_5_sizeof_bitfield`, and `6_7_2_1_bitfield_bad_type`. - [ ] `make test-parse` passes without skips: currently 2504 pass, 0 fail, 4 skip. Skips are `long double` and file-scope `asm`. - [x] `make test-cg-api test-opt test-dwarf test-debug` passes. @@ -66,6 +71,19 @@ are implemented. - [x] Reject non-power-of-two positive `aligned(N)` values. Test: `test/parse/cases_err/attr_p2_aligned_not_pow2.c`. Code: attribute argument parsing in `parse_type.c`. +- [ ] Reject the newly covered expression/type constraint failures now exposed + by `test/parse/cases_err/6_5_*`. + Current red: address of bit-field, cast struct to scalar, incompatible + conditional pointer arms, pointer-plus-pointer, incompatible pointer + relational compare, struct used as scalar condition, and `sizeof` on a + bit-field. +- [x] Reject additional initializer/declarator/tag constraints: + non-constant static initializer, excess scalar initializer, invalid + array/struct/union designators, wrong-kind tag redeclaration, functions + returning array/function, and variadic marker not last. +- [ ] Decide whether floating-point bit-fields are an extension. The + conformance test `6_7_2_1_bitfield_bad_type` currently expects rejection + and is red because `float f : 1` is accepted. Suggested cadence: @@ -112,14 +130,20 @@ CFREE_TEST_FILTER=asm_02_file_scope make test-parse `6_9_duplicate_parameter`. - [ ] Complete tag state handling for forward declarations, same-scope completion, and wrong-kind redeclarations. + New negative coverage: `6_7_2_tag_wrong_kind` passes. - [ ] Validate function declarator constraints: `void` parameter rules, variadic placement, function returning function, function returning array, array/function parameter adjustment. + New coverage: invalid variadic placement, function returning function, + and function returning array all pass as diagnostics; positive function + parameter adjustment is covered by `6_7_6_14_func_param_adjust`. - [ ] Decide and document implementation-defined bit-field behavior: plain `int` signedness, allowed extended bit-field types, allocation order, straddling, and alignment. - [ ] Add positive bit-field lowering cases from `test/parse/CORPUS.md`, including zero-width bit-fields. + Positive bit-field, signed bit-field, zero-width, and `_Bool` bit-field + cases pass; `float` bit-field rejection is still red. ## Expressions and conversions @@ -132,30 +156,47 @@ CFREE_TEST_FILTER=asm_02_file_scope make test-parse - [ ] Implement `sizeof` rules completely: no incomplete object type, no function type, no bit-field, VLA operand evaluated, non-VLA operand not evaluated. + New coverage: `sizeof(function)` is rejected and VLA/deref pointer + positive cases pass; `sizeof(bit-field)` is red because it is accepted. - [ ] Complete conditional operator usual-conversion behavior for arithmetic and pointer/null arms. + Positive arithmetic and pointer/null cases pass; incompatible pointer + arms are red because they are accepted. - [ ] Complete pointer compound assignment (`p += n`, `p -= n`). + Positive `p += n` coverage passes. - [ ] Expand `_Generic` tests for default selection, compatible types, and unevaluated controlling expression. + Default selection coverage passes. - [ ] Add negative tests for invalid pointer arithmetic, invalid relational comparisons, invalid casts, modifying non-lvalues, and scalar-required operators. + New negative tests are checked in. Current red: pointer-plus-pointer, + incompatible pointer relational compare, struct-to-int cast, and struct + condition accepted; array assignment is rejected. ## Constant expressions and initializers - [ ] Replace the current narrow integer evaluator with a C11-aware constant expression evaluator that tracks type, value category, and allowed forms. - [ ] Accept `_Alignof` in integer constant expressions. + Positive array-bound coverage passes. - [ ] Complete static initializer address constants: object address, function address, array plus/minus integer constant, and null pointer constants. + Positive object/function/array-plus-integer address constants pass. - [ ] Implement static-storage union initialization or document a temporary nonconformance gate. + Positive non-first union designated initializer passes. - [ ] Complete designated initializers: nested designators, enum-valued array designators, duplicate designator overwrite rules, non-first union member. + Positive nested, enum-valued, duplicate overwrite, and non-first union + coverage passes. - [ ] Add diagnostics for initializer overflow, excess scalar initializers, non-constant static initializers, and invalid designators. + New diagnostics for excess scalar initializers, non-constant static + initializers, and invalid array/struct/union designators pass. Overflow + diagnostics still need a precise C11 test case. ## Preprocessor and translation phases diff --git a/test/parse/CORPUS.md b/test/parse/CORPUS.md @@ -37,6 +37,8 @@ Sidecars (each missing file uses the documented default): ## Status legend - ★ landed (case present, parses, exit code matches) +- RED checked-in conformance case that currently fails and should stay red + until the implementation diagnoses or accepts it correctly - · planned (case registered, expected value fixed, parser doesn't accept it yet) - (deferred) — explicit non-goal for the current pass @@ -170,16 +172,16 @@ here for completeness once they're real cases. | `6_5_44_relational_all` | ★ | `(3>1)+(1<3)+(2<=2)+(2>=2)+(1!=2)+(2==2)` — covers `>`, `<=`, `>=`, `!=` | 6 | | `6_5_45_ptr_eq_null` | ★ | `(p==0)+(q!=0)+(p!=q)` — pointer equality with null and pointer-vs-pointer `!=` | 3 | | `6_5_46_ptr_relcmp` | ★ | `(p<q)+(q>p)+(p<=p)` — relational comparison of pointers into same array | 3 | -| `6_5_47_ternary_arith_conv` | · | `int c=1; double r = c ? 1 : 2.5; return (int)(r+41.0);` — ternary arms get usual arithmetic conversion to double | 42 | +| `6_5_47_ternary_arith_conv` | ★ | `int c=1; double r = c ? 1 : 2.5; return (int)(r+41.0);` — ternary arms get usual arithmetic conversion to double | 42 | | `6_5_48_ternary_ptr_null` | ★ | `int *p = 1 ? &x : 0; return *p;` — one arm pointer, other null pointer constant | 42 | | `6_5_49_compound_assign_sub` | ★ | `int x=44; x-=2; return x;` — `-=` operator | 42 | | `6_5_50_compound_assign_shift` | ★ | `int x=336; x>>=3; return x;` — `>>=` operator (336>>3=42) | 42 | | `6_5_51_compound_assign_bitwise` | ★ | `x=0xff; x&=0x7f; x^=0x55; x\|=0x00;` — `&=`, `^=`, `\|=` | 42 | -| `6_5_52_compound_assign_ptr` | · | `int *p=a; p+=4; return *p;` — `+=` with pointer LHS | 42 | -| `6_5_53_sizeof_vla_runtime` | · | `int n=7; int a[n]; return (int)sizeof(a);` — sizeof on VLA evaluated at runtime | 28 | -| `6_5_54_sizeof_deref_ptr` | · | `double *p=&x; return (int)sizeof(*p);` — sizeof on dereferenced pointer; operand not evaluated | 8 | -| `6_5_55_generic_default_branch` | · | `_Generic((double)x, int: 0, default: 42)` — falls through to `default` | 42 | -| `6_5_56_compound_literal_struct` | · | `struct S s = (struct S){.a=20,.b=22}; return s.a+s.b;` — struct compound literal with designated init | 42 | +| `6_5_52_compound_assign_ptr` | ★ | `int *p=a; p+=4; return *p;` — `+=` with pointer LHS | 42 | +| `6_5_53_sizeof_vla_runtime` | ★ | `int n=7; int a[n]; return (int)sizeof(a);` — sizeof on VLA evaluated at runtime | 28 | +| `6_5_54_sizeof_deref_ptr` | ★ | `double *p=&x; return (int)sizeof(*p);` — sizeof on dereferenced pointer; operand not evaluated | 8 | +| `6_5_55_generic_default_branch` | ★ | `_Generic((double)x, int: 0, default: 42)` — falls through to `default` | 42 | +| `6_5_56_compound_literal_struct` | ★ | `struct S s = (struct S){.a=20,.b=22}; return s.a+s.b;` — struct compound literal with designated init | 42 | | `6_5_57_unsigned_wrap_add` | ★ | `unsigned x=0xFFFFFFFFU; x+=1; return (int)(x & 0xff);` — unsigned addition wraps modulo 2^32 | 0 | ## §6.5.2.2 Aggregate function arguments @@ -205,9 +207,9 @@ copy (BYVAL). Each row exercises one cell of the (1-reg / 2-reg / copy) | `6_6_01_enum_const` | ★ | `enum { K = 42 }; return K;` | 42 | | `6_6_02_const_expr_init` | ★ | `int x = 1+2*3; return x;` | 7 | | `6_6_03_array_size_const` | ★ | `int a[3+4] = {0}; return (int)sizeof a / (int)sizeof a[0];` | 7 | -| `6_6_04_alignof_array_size` | · | `int a[_Alignof(long long)]; return (int)sizeof(a)/sizeof(a[0]);` — `_Alignof` in array-size constant | 8 | -| `6_6_05_addr_const_static_init` | · | full TU: `static int g=7; static int *p=&g; ...return *p*6;` — address constant in static initializer | 42 | -| `6_6_06_addr_const_arith_init` | · | full TU: `static int arr[4]={0,0,0,42}; static int *p=arr+3; ...return *p;` — address constant + ICE in static initializer | 42 | +| `6_6_04_alignof_array_size` | ★ | `int a[_Alignof(long long)]; return (int)sizeof(a)/sizeof(a[0]);` — `_Alignof` in array-size constant | 8 | +| `6_6_05_addr_const_static_init` | ★ | full TU: `static int g=7; static int *p=&g; ...return *p*6;` — address constant in static initializer | 42 | +| `6_6_06_addr_const_arith_init` | ★ | full TU: `static int arr[4]={0,0,0,42}; static int *p=arr+3; ...return *p;` — address constant + ICE in static initializer | 42 | | `6_6_07_enum_array_bound` | ★ | file scope: `typedef enum {A,B,C,N} E; static const int marks[N]={10,12,20};` — enum constant as array bound | 42 | | `6_6_08_func_addr_static_init` | ★ | `static int helper(int x){return x;}` + `static const FN g = helper;` — function designator as static-init address constant (no `&`) | 42 | | `6_6_09_func_addr_array_static` | ★ | `static const FN ops[2] = {add1, dbl};` — array of function-pointer static-init constants | 42 | @@ -268,14 +270,14 @@ members, self-reference through pointers, and forward declarations. | Case | Status | Body | Expected | |---|---|---|---| -| `6_7_2_1_01_bitfield` | · | `struct {unsigned a:5, b:3;} s={2,5}; return s.b*8 + s.a;` | 42 | +| `6_7_2_1_01_bitfield` | ★ | `struct {unsigned a:5, b:3;} s={2,5}; return s.b*8 + s.a;` | 42 | | `6_7_2_1_02_anon_struct` | ★ | `struct S{int x; struct{int y;};} s={0,42}; return s.y;` | 42 | | `6_7_2_1_03_anon_union` | ★ | `struct S{int x; union{int a,b;};} s; s.x=0; s.a=42; return s.b;` | 42 | | `6_7_2_1_04_self_ref` | ★ | `struct N{int v; struct N *next;}; struct N b={42,0}, a={0,&b}; return a.next->v;` | 42 | | `6_7_2_1_05_forward_tag` | ★ | `struct S; struct S *p; struct S{int v;}; struct S s={42}; p=&s; return p->v;` | 42 | | `6_7_2_1_06_flex_array` | (deferred) | flexible array members need allocator support | — | | `6_7_2_1_07_signed_bitfield` | ★ | `struct {signed int s:8;} b={-1}; return (b.s<0)?42:0;` — signed bitfield sign extension | 42 | -| `6_7_2_1_08_zero_width_bitfield` | · | `struct {unsigned a:4; unsigned:0; unsigned b:4;}` — zero-width bitfield forces next field into new storage unit | 42 | +| `6_7_2_1_08_zero_width_bitfield` | ★ | `struct {unsigned a:4; unsigned:0; unsigned b:4;}` — zero-width bitfield forces next field into new storage unit | 42 | | `6_7_2_1_09_bool_bitfield` | ★ | `struct {_Bool b:1;} s; s.b=1; return s.b?42:0;` — `_Bool` bitfield | 42 | ## §6.7.2.2 Enumeration specifiers @@ -331,7 +333,7 @@ already exercised in §6.5 and §6.7. | Case | Status | Body | Expected | |---|---|---|---| | `6_7_6_01_ptr_to_ptr` | ★ | `int x=42; int *p=&x; int **pp=&p; return **pp;` | 42 | -| `6_7_6_02_array_2d` | · | `int a[2][3]={{0,0,0},{0,0,42}}; return a[1][2];` | 42 | +| `6_7_6_02_array_2d` | ★ | `int a[2][3]={{0,0,0},{0,0,42}}; return a[1][2];` | 42 | | `6_7_6_03_array_of_ptr` | ★ | `int x=42; int *a[2]={0,&x}; return *a[1];` | 42 | | `6_7_6_04_funcptr_decl` | ★ | `int id(int x){return x;} int (*fp)(int)=id; return fp(42);` | 42 | | `6_7_6_05_funcptr_returning_ptr` | ★ | helper returns `int*`; `int *(*fp)(int*)=...; return *fp(&x);` | 42 | @@ -339,10 +341,11 @@ already exercised in §6.5 and §6.7. | `6_7_6_07_vla_local` | ★ | `int n=7; int a[n]; for(int i=0;i<n;i++) a[i]=i*7; return a[n-1];` | 42 | | `6_7_6_08_variadic_decl` | ★ | helper `int sum(int n, ...)` summing two ints; `sum(2, 20, 22)` | 42 | | `6_7_6_09_ptr_to_array` | ★ | `int b[3]={0,0,42}; int (*pa)[3]=&b; return (*pa)[2];` — pointer-to-array declarator | 42 | -| `6_7_6_10_array_of_funcptr` | · | `int (*ops[2])(int)={add1,sub1}; return ops[0](ops[1](42));` — block-scope array of function pointers | 42 | +| `6_7_6_10_array_of_funcptr` | ★ | `int (*ops[2])(int)={add1,sub1}; return ops[0](ops[1](42));` — block-scope array of function pointers | 42 | | `6_7_6_11_func_returning_funcptr` | ★ | `typedef int (*FP)(int); FP getfp(void){return id;} return getfp()(42);` — function returning function pointer | 42 | -| `6_7_6_12_vla_param` | · | `int sum_vla(int n, int a[n]){...}` — VLA dimension from earlier param; param adjusted to pointer | 42 | -| `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_12_vla_param` | ★ | `int sum_vla(int n, int a[n]){...}` — VLA dimension from earlier param; param adjusted to pointer | 42 | +| `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.7 Type names @@ -381,9 +384,9 @@ cover compound typedef targets. | `6_7_9_11_array_size_from_init` | ★ | `int x[] = {10, 12, 20}; return x[0]+x[1]+x[2];` — array of unknown size; size from init list | 42 | | `6_7_9_12_designator_override` | ★ | `int a[3] = {[1]=99, [1]=42, [0]=0};` — later designator overrides earlier | 42 | | `6_7_9_13_string_init_fixed_larger` | ★ | `char s[6] = "hi";` — char array larger than string literal; excess elements zero-filled (sum = 'h'+'i'+0+0+0+0) | 209 | -| `6_7_9_14_struct_copy_init` | · | `struct S src={20,22}; struct S dst=src; return dst.a+dst.b;` — struct init from compatible struct expression | 42 | -| `6_7_9_15_union_designated_nonfirst` | · | `union U{int a; int b;} u={.b=42}; return u.b;` — designated init of non-first union member | 42 | -| `6_7_9_16_enum_designator` | · | `enum {X=2}; int a[4]={[X]=42}; return a[X];` — enum constant as array designator | 42 | +| `6_7_9_14_struct_copy_init` | ★ | `struct S src={20,22}; struct S dst=src; return dst.a+dst.b;` — struct init from compatible struct expression | 42 | +| `6_7_9_15_union_designated_nonfirst` | ★ | `union U{int a; int b;} u={.b=42}; return u.b;` — designated init of non-first union member | 42 | +| `6_7_9_16_enum_designator` | ★ | `enum {X=2}; int a[4]={[X]=42}; return a[X];` — enum constant as array designator | 42 | | `6_7_9_17_inconsistent_bracket_init` | ★ | `struct T{int a[2];int b;} w[2]={{1},2};` — flat init consumed into subaggregate without inner braces | 3 | | `6_7_9_18_static_init_string_ptr` | ★ | `static const S g = { .s = "hi" };` — string literal as address constant in pointer-slot static init | 209 | | `6_7_9_19_static_init_string_array` | ★ | `static const char* const names[2] = {"a","b"};` — array-of-pointer static init with string literals | 42 | @@ -515,8 +518,18 @@ cursor, so mixed and class-only sequences both need direct exercise. | Case | Status | Surface | Notes | |---|---|---|---| | `6_5_undeclared` | · | identifier resolution | `return q;` | +| `6_5_addr_of_bitfield` | RED | lvalue / bit-field | address of a bit-field must be rejected; currently accepted | +| `6_5_cast_scalar_from_struct` | RED | cast constraints | casting a struct expression to `int` must be rejected; currently accepted | +| `6_5_cond_incompatible_ptr` | RED | conditional operator | `int *` vs `double *` arms are incompatible; currently accepted | | `6_5_lvalue_required` | · | assignment LHS | `1 = 2;` | +| `6_5_lvalue_array_assign` | ★ | assignment LHS | assigning to an array object | +| `6_5_pointer_add_pointer` | RED | pointer arithmetic | `p + q` for two pointers must be rejected; currently accepted | +| `6_5_rel_incompatible_ptr` | RED | pointer comparison | relational compare of incompatible pointer types; currently accepted | +| `6_5_scalar_required_if` | RED | scalar expression | struct expression used as `if` condition; currently accepted | +| `6_5_sizeof_bitfield` | RED | sizeof | `sizeof` cannot be applied to a bit-field; currently accepted | +| `6_5_sizeof_function` | ★ | sizeof | `sizeof` cannot be applied to a function designator | | `6_5_type_mismatch` | · | implicit conversion | assigning `int*` to `int` | +| `6_6_static_init_nonconstant` | ★ | static initializer | file-scope static initializer from non-constant object | | `6_7_redefinition` | · | linkage / scope | two `int x = …` at file scope | | `6_8_break_outside_loop` | · | break/continue scope | `break;` outside iteration | | `6_9_redefinition_function` | · | external definition | two definitions of `f` | @@ -525,9 +538,21 @@ cursor, so mixed and class-only sequences both need direct exercise. | `6_5_arrow_on_non_pointer` | · | member access | `struct S s; s->v;` | | `6_5_sizeof_incomplete` | · | sizeof | `struct S; return sizeof(struct S);` | | `6_7_2_storage_class_combo` | · | declaration | `static extern int x;` | +| `6_7_2_tag_wrong_kind` | ★ | tag | redeclaring a `struct` tag as a `union` in the same scope | +| `6_7_2_1_bitfield_bad_type` | RED | bitfield | `float` bit-field accepted pending extended-type policy | +| `6_7_2_1_bitfield_named_zero_width` | ★ | bitfield | named zero-width bit-field | +| `6_7_2_1_bitfield_negative_width` | ★ | bitfield | negative bit-field width | +| `6_7_2_1_bitfield_nonconstant_width` | ★ | bitfield | bit-field width that is not an integer constant expression | | `6_7_2_two_struct_defs` | · | tag | two `struct S { ... };` definitions in same scope | | `6_7_2_1_bitfield_too_wide` | · | bitfield | `unsigned a:33;` exceeds underlying type | | `6_7_3_const_assign` | · | const violation | `const int x = 0; x = 1;` | +| `6_7_6_function_returning_array` | ★ | function declarator | function returning array | +| `6_7_6_function_returning_function` | ★ | function declarator | function returning function | +| `6_7_6_variadic_not_last` | ★ | function declarator | variadic marker not in final position | +| `6_7_9_excess_scalar_init` | ★ | initializer | too many initializers for scalar object | +| `6_7_9_invalid_array_designator` | ★ | initializer | array designator index that is not an integer constant expression | +| `6_7_9_invalid_struct_designator` | ★ | initializer | designator names no member of the target struct | +| `6_7_9_invalid_union_designator` | ★ | initializer | designator names no member of the target union | | `6_7_10_static_assert_fail` | ★ | static assertion | `_Static_assert(0, "fail");` | | `6_8_case_outside_switch` | · | switch scope | `case 1:` outside any switch | | `6_8_continue_outside_loop` | · | iteration scope | `continue;` outside iteration | diff --git a/test/parse/cases/6_7_6_14_func_param_adjust.c b/test/parse/cases/6_7_6_14_func_param_adjust.c @@ -0,0 +1,9 @@ +int inc(int x) { return x + 1; } + +int apply(int f(int), int x) { + return f(x); +} + +int test_main(void) { + return apply(inc, 41); +} diff --git a/test/parse/cases/6_7_6_14_func_param_adjust.expected b/test/parse/cases/6_7_6_14_func_param_adjust.expected @@ -0,0 +1 @@ +42 diff --git a/test/parse/cases_err/6_5_addr_of_bitfield.c b/test/parse/cases_err/6_5_addr_of_bitfield.c @@ -0,0 +1,5 @@ +int test_main(void) { + struct S { unsigned a : 3; } s = {1}; + unsigned *p = &s.a; + return (int)*p; +} diff --git a/test/parse/cases_err/6_5_cast_scalar_from_struct.c b/test/parse/cases_err/6_5_cast_scalar_from_struct.c @@ -0,0 +1,4 @@ +int test_main(void) { + struct S { int v; } s = {42}; + return (int)s; +} diff --git a/test/parse/cases_err/6_5_cond_incompatible_ptr.c b/test/parse/cases_err/6_5_cond_incompatible_ptr.c @@ -0,0 +1,6 @@ +int test_main(void) { + int i = 0; + double d = 0.0; + void *p = 1 ? &i : &d; + return p != 0; +} diff --git a/test/parse/cases_err/6_5_lvalue_array_assign.c b/test/parse/cases_err/6_5_lvalue_array_assign.c @@ -0,0 +1,6 @@ +int test_main(void) { + int a[2] = {1, 2}; + int b[2] = {3, 4}; + a = b; + return a[0]; +} diff --git a/test/parse/cases_err/6_5_pointer_add_pointer.c b/test/parse/cases_err/6_5_pointer_add_pointer.c @@ -0,0 +1,6 @@ +int test_main(void) { + int a[2] = {0, 1}; + int *p = a; + int *q = a + 1; + return (int)(p + q); +} diff --git a/test/parse/cases_err/6_5_rel_incompatible_ptr.c b/test/parse/cases_err/6_5_rel_incompatible_ptr.c @@ -0,0 +1,5 @@ +int test_main(void) { + int i = 0; + double d = 0.0; + return &i < &d; +} diff --git a/test/parse/cases_err/6_5_scalar_required_if.c b/test/parse/cases_err/6_5_scalar_required_if.c @@ -0,0 +1,5 @@ +int test_main(void) { + struct S { int v; } s = {42}; + if (s) return 1; + return 0; +} diff --git a/test/parse/cases_err/6_5_sizeof_bitfield.c b/test/parse/cases_err/6_5_sizeof_bitfield.c @@ -0,0 +1,4 @@ +int test_main(void) { + struct S { unsigned a : 3; } s = {1}; + return (int)sizeof(s.a); +} diff --git a/test/parse/cases_err/6_5_sizeof_function.c b/test/parse/cases_err/6_5_sizeof_function.c @@ -0,0 +1,5 @@ +int f(void); + +int test_main(void) { + return (int)sizeof(f); +} diff --git a/test/parse/cases_err/6_6_static_init_nonconstant.c b/test/parse/cases_err/6_6_static_init_nonconstant.c @@ -0,0 +1,6 @@ +int g = 1; +static int x = g; + +int test_main(void) { + return x; +} diff --git a/test/parse/cases_err/6_7_2_1_bitfield_bad_type.c b/test/parse/cases_err/6_7_2_1_bitfield_bad_type.c @@ -0,0 +1,7 @@ +struct S { + float f : 1; +}; + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_2_1_bitfield_named_zero_width.c b/test/parse/cases_err/6_7_2_1_bitfield_named_zero_width.c @@ -0,0 +1,7 @@ +struct S { + unsigned a : 0; +}; + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_2_1_bitfield_negative_width.c b/test/parse/cases_err/6_7_2_1_bitfield_negative_width.c @@ -0,0 +1,7 @@ +struct S { + unsigned a : -1; +}; + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_2_1_bitfield_nonconstant_width.c b/test/parse/cases_err/6_7_2_1_bitfield_nonconstant_width.c @@ -0,0 +1,5 @@ +int test_main(void) { + int n = 3; + struct S { unsigned a : n; } s = {1}; + return s.a; +} diff --git a/test/parse/cases_err/6_7_2_tag_wrong_kind.c b/test/parse/cases_err/6_7_2_tag_wrong_kind.c @@ -0,0 +1,6 @@ +struct T; +union T { int v; }; + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_6_function_returning_array.c b/test/parse/cases_err/6_7_6_function_returning_array.c @@ -0,0 +1,5 @@ +int f(void)[3]; + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_6_function_returning_function.c b/test/parse/cases_err/6_7_6_function_returning_function.c @@ -0,0 +1,5 @@ +int f(void)(void); + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_6_variadic_not_last.c b/test/parse/cases_err/6_7_6_variadic_not_last.c @@ -0,0 +1,5 @@ +int f(int, ..., int); + +int test_main(void) { + return 0; +} diff --git a/test/parse/cases_err/6_7_9_excess_scalar_init.c b/test/parse/cases_err/6_7_9_excess_scalar_init.c @@ -0,0 +1,4 @@ +int test_main(void) { + int x = {1, 2}; + return x; +} diff --git a/test/parse/cases_err/6_7_9_invalid_array_designator.c b/test/parse/cases_err/6_7_9_invalid_array_designator.c @@ -0,0 +1,5 @@ +int test_main(void) { + int i = 1; + int a[3] = {[i] = 42}; + return a[1]; +} diff --git a/test/parse/cases_err/6_7_9_invalid_struct_designator.c b/test/parse/cases_err/6_7_9_invalid_struct_designator.c @@ -0,0 +1,4 @@ +int test_main(void) { + struct S { int a; } s = {.b = 42}; + return s.a; +} diff --git a/test/parse/cases_err/6_7_9_invalid_union_designator.c b/test/parse/cases_err/6_7_9_invalid_union_designator.c @@ -0,0 +1,4 @@ +int test_main(void) { + union U { int a; int b; } u = {.c = 42}; + return u.a; +}