Improve error checking for unsized arrays.
Added support for resolving dimensions of multi-dimensional unsized arrays from their initializer exprerssions (previously, only the first dimension would be resolved.) Added checks to make sure that no unsized array dimensions remain after doing this (except for the first dimensision of array parameters to functions.)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Can't declare an unsized array as a local variable without providing an initializer expression to set its size
|
||||
// Illegal to declare an unsized array variable without providing an initializer expression to set its size
|
||||
|
||||
int func() {
|
||||
int a[];
|
||||
|
||||
3
tests_errors/initexpr-2.ispc
Normal file
3
tests_errors/initexpr-2.ispc
Normal file
@@ -0,0 +1,3 @@
|
||||
// Initializer list for array "int32[2][4]" must have 2 elements (has 3).
|
||||
|
||||
int a[2][4] = { { 1, 2, 3 }, { 1, 2, 3, 4 }, 1 };
|
||||
6
tests_errors/initexpr-3.ispc
Normal file
6
tests_errors/initexpr-3.ispc
Normal file
@@ -0,0 +1,6 @@
|
||||
// Inconsistent expression list lengths found in initializer list
|
||||
|
||||
void foo() {
|
||||
int a[2][] = { { 1, 2, 3 }, { 1, 2, 3, 4 } };
|
||||
}
|
||||
|
||||
4
tests_errors/initexpr-4.ispc
Normal file
4
tests_errors/initexpr-4.ispc
Normal file
@@ -0,0 +1,4 @@
|
||||
// Illegal to declare an unsized array variable without providing an initializer expression to set its size
|
||||
|
||||
void foo() { int a[][]; }
|
||||
|
||||
4
tests_errors/initexpr-6.ispc
Normal file
4
tests_errors/initexpr-6.ispc
Normal file
@@ -0,0 +1,4 @@
|
||||
// Illegal to declare a global variable with unsized array dimensions that aren't set with an initializer expression
|
||||
|
||||
int a[][];
|
||||
|
||||
3
tests_errors/initexpr.ispc
Normal file
3
tests_errors/initexpr.ispc
Normal file
@@ -0,0 +1,3 @@
|
||||
// Initializer list for array "int32[4]" must have 4 elements
|
||||
|
||||
int a[2][4] = { { 1, 2, 3 }, { 1, 2, 3, 4 } };
|
||||
4
tests_errors/unsized-funcparam.ispc
Normal file
4
tests_errors/unsized-funcparam.ispc
Normal file
@@ -0,0 +1,4 @@
|
||||
// Arrays with unsized dimensions in dimensions after the first one are illegal in function parameter lists
|
||||
|
||||
void func(int a[1][]) {
|
||||
}
|
||||
Reference in New Issue
Block a user