Commit 8824edff by Jakub Jelinek Committed by Jakub Jelinek

re PR c/56078 (causes cc1 to crash)

	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
parent 1513a0d4
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
......
......@@ -7574,7 +7574,9 @@ set_nonincremental_init_from_string (tree str,
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)
......@@ -8106,9 +8108,9 @@ process_init_element (struct c_expr value, bool implicit,
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
......
......@@ -12,7 +12,7 @@ typedef struct {
} 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)" } */
};
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment