From 8824edffd65df2586dac35322a6c9feb465959ad Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 24 Jan 2013 17:59:44 +0100 Subject: 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 --- gcc/c/ChangeLog | 8 ++++++++ gcc/c/c-typeck.c | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3acb88a..b78666c 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2013-01-24 Jakub Jelinek + + 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 PR c++/55619 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index ccb402c..ddb6d39 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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 -- cgit v1.1