Skip to content

ansi-c/Array_Declarator* regression tests: front end is too permissive #132

Open
@tautschnig

Description

@tautschnig

These are marked KNOWNBUG at the moment, because goto-cc accepts what gcc wouldn't:

Array_Declarator2/main.c:5:18: error: variable length array must be bound in function definition
void fooStar(int x[*])
                 ^
1 error generated.
$ gcc Array_Declarator3/main.c
Array_Declarator3/main.c:7:11: error: type qualifier used in array declarator outside of function prototype
  int bar0[restrict] = {0};
          ^
1 error generated.
$ gcc Array_Declarator4/main.c
Array_Declarator4/main.c:7:11: error: 'static' used in array declarator outside of function prototype
  int bar1[static 1U] = {1};
          ^
1 error generated.
$ gcc Array_Declarator5/main.c
Array_Declarator5/main.c:7:11: error: type qualifier used in array declarator outside of function prototype
  int bar2[restrict 2U] = {1, 2};
          ^
1 error generated.
$ gcc Array_Declarator6/main.c
Array_Declarator6/main.c:7:11: error: 'static' used in array declarator outside of function prototype
  int bar3[restrict static 3U] = {1, 2, 3};
          ^
1 error generated.
$ gcc Array_Declarator7/main.c
Array_Declarator7/main.c:7:11: error: 'static' used in array declarator outside of function prototype
  int bar4[static restrict 4U] = {1, 2, 3, 4};
          ^
1 error generated.

It may be debatable whether the C front end really needs to produce errors here, it safely ignores these extra qualifiers anyway.

Best,
Michael

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions