+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
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;
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))
+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
--- /dev/null
+/* 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" };
--- /dev/null
+/* 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" } */