re PR c/42262 (internal compiler error: in set_designator, at c-typeck.c:5771)
PR c/42262 c: * c-typeck.c (process_init_element): Do not treat a string as initializing a whole array when used with a designator for an individual element. testsuite: * gcc.dg/c99-init-5.c, gcc.dg/c99-init-6.c: New tests. From-SVN: r205543
This commit is contained in:
parent
3163a5cab5
commit
340baef702
5 changed files with 29 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
2013-11-29 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
PR c/42262
|
||||
* c-typeck.c (process_init_element): Do not treat a string as
|
||||
initializing a whole array when used with a designator for an
|
||||
individual element.
|
||||
|
||||
2013-11-29 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
PR c/57574
|
||||
|
|
|
@ -8504,6 +8504,7 @@ process_init_element (struct c_expr value, bool implicit,
|
|||
tree orig_value = value.value;
|
||||
int string_flag = orig_value != 0 && TREE_CODE (orig_value) == STRING_CST;
|
||||
bool strict_string = value.original_code == STRING_CST;
|
||||
bool was_designated = designator_depth != 0;
|
||||
|
||||
designator_depth = 0;
|
||||
designator_erroneous = 0;
|
||||
|
@ -8512,6 +8513,7 @@ process_init_element (struct c_expr value, bool implicit,
|
|||
char x[] = {"foo"}; */
|
||||
if (string_flag
|
||||
&& constructor_type
|
||||
&& !was_designated
|
||||
&& TREE_CODE (constructor_type) == ARRAY_TYPE
|
||||
&& INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
|
||||
&& integer_zerop (constructor_unfilled_index))
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2013-11-29 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
PR c/42262
|
||||
* gcc.dg/c99-init-5.c, gcc.dg/c99-init-6.c: New tests.
|
||||
|
||||
2013-11-29 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* lib/asan-dg.exp (asan_link_flags): Properly add path to
|
||||
|
|
9
gcc/testsuite/gcc.dg/c99-init-5.c
Normal file
9
gcc/testsuite/gcc.dg/c99-init-5.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* Test for designated initializers: string constants used with
|
||||
designator in character array should not initialize the array as a
|
||||
whole. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
||||
|
||||
char g[] = { [7] = "abcd" }; /* { dg-error "initial" } */
|
||||
char h[10][10] = { [1][1] = "abcd" }; /* { dg-error "initial" } */
|
||||
char i[10][10] = { [1] = "abcd" };
|
6
gcc/testsuite/gcc.dg/c99-init-6.c
Normal file
6
gcc/testsuite/gcc.dg/c99-init-6.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* Test for designated initializers: invalid uses of string constants
|
||||
should not ICE. PR 42262. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
||||
|
||||
int a[] = { [0 ... 1] = "", [0] = "" }; /* { dg-error "initial" } */
|
Loading…
Add table
Reference in a new issue