PR c/56078
* c-typeck.c (set_nonincremental_init_from_string): If
constructor_max_index is NULL, treat it as if tree_int_cst_lt
returned false.
(process_init_element): Likewise.
* gcc.dg/pr56078.c: New test.
* gcc.c-torture/compile/
20030305-1.c: Add dg-error lines.
From-SVN: r195432
+2013-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/56078
+ * c-typeck.c (set_nonincremental_init_from_string): If
+ constructor_max_index is NULL, treat it as if tree_int_cst_lt
+ returned false.
+ (process_init_element): Likewise.
+
2012-12-20 Jakub Jelinek <jakub@redhat.com>
PR c++/55619
end = p + TREE_STRING_LENGTH (str);
for (purpose = bitsize_zero_node;
- p < end && !tree_int_cst_lt (constructor_max_index, purpose);
+ p < end
+ && !(constructor_max_index
+ && tree_int_cst_lt (constructor_max_index, purpose));
purpose = size_binop (PLUS_EXPR, purpose, bitsize_one_node))
{
if (wchar_bytes == 1)
true, braced_init_obstack);
else if ((TREE_CODE (constructor_type) == ARRAY_TYPE
|| TREE_CODE (constructor_type) == VECTOR_TYPE)
- && (constructor_max_index == 0
- || tree_int_cst_lt (constructor_max_index,
- constructor_index)))
+ && constructor_max_index
+ && tree_int_cst_lt (constructor_max_index,
+ constructor_index))
process_init_element (pop_init_level (1, braced_init_obstack),
true, braced_init_obstack);
else
+2013-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/56078
+ * gcc.dg/pr56078.c: New test.
+ * gcc.c-torture/compile/20030305-1.c: Add dg-error lines.
+
2013-01-24 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/55927
} s2_t;
static s2_t s2_array[]= {
- { 1, 4 },
- { 2, 5 },
- { 3, 6 }
+ { 1, 4 }, /* { dg-error "(initialization of flexible array member|near)" } */
+ { 2, 5 }, /* { dg-error "(initialization of flexible array member|near)" } */
+ { 3, 6 } /* { dg-error "(initialization of flexible array member|near)" } */
};
--- /dev/null
+/* PR c/56078 */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern int memcmp (const void *, const void *, size_t);
+extern void abort (void);
+
+struct T { int a; char b[]; };
+struct T t1 = { .a = 1, .b = "abcd", .b[0] = '2' };
+struct T t2 = { .a = 1, .b = "2bcd" };
+struct T t3 = { .a = 1, .b[2] = 'a' };
+struct T t4 = { .a = 1, .b = { '\0', '\0', 'a' } };
+struct T t5 = { .a = 1, .b = { [0] = 'a', [1] = 'b', [2] = 'c' } };
+struct T t6 = { .a = 1, .b[2] = 'c', .b[1] = 'x', .b[0] = 'a', .b[1] = 'b' };
+
+int
+main ()
+{
+ if (memcmp (t1.b, t2.b, sizeof ("abcd")) != 0
+ || memcmp (t3.b, t4.b, 3) != 0
+ || memcmp (t5.b, t6.b, 3) != 0)
+ abort ();
+ return 0;
+}