Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/src/dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -2994,10 +2994,6 @@ final class CParser(AST) : Parser!AST
{
error("variable length arrays are not supported");
}
if (isStatic) // C11 6.7.6.3
{
error("static array parameters are not supported");
}
if (declarator != DTR.xparameter)
{
/* C11 6.7.6.2-4: '*' can only be used with function prototype scope.
Expand Down
2 changes: 0 additions & 2 deletions compiler/test/fail_compilation/failcstuff1.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ fail_compilation/failcstuff1.c(260): Error: expected identifier for declarator
fail_compilation/failcstuff1.c(301): Error: illegal type combination
fail_compilation/failcstuff1.c(352): Error: found `2` when expecting `:`
fail_compilation/failcstuff1.c(352): Error: found `:` instead of statement
fail_compilation/failcstuff1.c(450): Error: static array parameters are not supported
fail_compilation/failcstuff1.c(450): Error: static or type qualifier used in non-outermost array type derivation
fail_compilation/failcstuff1.c(451): Error: static or type qualifier used in non-outermost array type derivation
fail_compilation/failcstuff1.c(451): Error: array type has incomplete element type `int[0]`
fail_compilation/failcstuff1.c(452): Error: array type has incomplete element type `int[0]`
fail_compilation/failcstuff1.c(453): Error: array type has incomplete element type `int[0]`
fail_compilation/failcstuff1.c(454): Error: found `const` when expecting `,`
fail_compilation/failcstuff1.c(458): Error: static array parameters are not supported
fail_compilation/failcstuff1.c(458): Error: static or type qualifier used outside of function prototype
fail_compilation/failcstuff1.c(459): Error: static or type qualifier used outside of function prototype
fail_compilation/failcstuff1.c(460): Error: variable length arrays are not supported
Expand Down
28 changes: 28 additions & 0 deletions compiler/test/runnable/test22790.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// https://github.com/dlang/dmd/issues/22790

void test_static(int array[static 4]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the D type of this function?
void function(int*) or void function(int[4]*)?

_Static_assert(sizeof(array) == sizeof(int*), "array must decay to pointer");
}

void f1 (int[static 1 + 1]);
// sizeof a fails with undefined identifier 'a' since previous parameters aren't in scope yet.
// void f2 (int a, int x[static sizeof(a)]);

void f1a (int a[static 2])
{
int **b = &a;
int *const *c = &a;
}

void f3a (int a[static const 2])
{
int **b = &a;
int *const *c = &a;
}

int main()
{
int a[4];
test_static(a);
return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not asserting anything at run time, can you remove main and make it compilable? Runnable tests are very slow.

}
Loading