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:
Matt Pharr
2011-11-21 09:16:29 -08:00
parent 068ea3e4c4
commit d3e6879223
13 changed files with 140 additions and 29 deletions

View File

@@ -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[];

View 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 };

View 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 } };
}

View 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[][]; }

View 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[][];

View 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 } };

View 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][]) {
}