Allow fewer initializer values in initializer expr lists than expected.

We now match C's behavior, where if we have an initializer list with
too-few values for the underlying type, any additional elements are
initialized to zero.

Fixes issue #123.
This commit is contained in:
Matt Pharr
2012-02-14 13:47:11 -08:00
parent c63d139482
commit 317a1f51f7
5 changed files with 57 additions and 32 deletions

View File

@@ -1,5 +0,0 @@
// requires 10 values; 11 provided
int func() {
int a[10] = {1,2,3,4,5,6,7,8,9,10,11};
}

View File

@@ -1,5 +0,0 @@
// requires 12 values; 11 provided
int func() {
int a[12] = {1,2,3,4,5,6,7,8,9,10,11};
}

View File

@@ -1,3 +1,3 @@
// Initializer list for array "int32[4]" must have 4 elements (has 3)
// Initializer list for array "int32[2][4]" must have no more than 2 elements (has 3)
int a[2][4] = { { 1, 2, 3 }, { 1, 2, 3, 4 }, 1 };

View File

@@ -1,3 +0,0 @@
// Initializer list for array "int32[4]" must have 4 elements
int a[2][4] = { { 1, 2, 3 }, { 1, 2, 3, 4 } };