Commit 822baa84 by Jakub Jelinek Committed by Jakub Jelinek

c-typeck.c (output_init_element): Call digest_init just once...

	* c-typeck.c (output_init_element): Call digest_init
	just once, not in each if branch and check its return value for
	error_mark_node.

	* gcc.dg/noncompile/20011025-1.c: New test.

From-SVN: r47673
parent a3315b53
2001-12-05 Jakub Jelinek <jakub@redhat.com> 2001-12-05 Jakub Jelinek <jakub@redhat.com>
* c-typeck.c (output_init_element): Call digest_init
just once, not in each if branch and check its return value for
error_mark_node.
2001-12-05 Jakub Jelinek <jakub@redhat.com>
* c-decl.c (pushdecl): Only increase n_incomplete if pushed decl's * c-decl.c (pushdecl): Only increase n_incomplete if pushed decl's
type is RECORD_TYPE, UNION_TYPE or ARRAY_TYPE thereof. type is RECORD_TYPE, UNION_TYPE or ARRAY_TYPE thereof.
(finish_struct): Break the loop if n_incomplete went to 0. (finish_struct): Break the loop if n_incomplete went to 0.
......
...@@ -4701,7 +4701,7 @@ digest_init (type, init, require_constant, constructor_constant) ...@@ -4701,7 +4701,7 @@ digest_init (type, init, require_constant, constructor_constant)
if (type == error_mark_node if (type == error_mark_node
|| init == error_mark_node || init == error_mark_node
|| TREE_TYPE (init) == error_mark_node) || TREE_TYPE (init) == error_mark_node)
return error_mark_node; return error_mark_node;
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
...@@ -6267,6 +6267,8 @@ output_init_element (value, type, field, pending) ...@@ -6267,6 +6267,8 @@ output_init_element (value, type, field, pending)
|| TREE_CHAIN (field))))) || TREE_CHAIN (field)))))
return; return;
value = digest_init (type, value, require_constant_value,
require_constant_elements);
if (value == error_mark_node) if (value == error_mark_node)
{ {
constructor_erroneous = 1; constructor_erroneous = 1;
...@@ -6283,9 +6285,7 @@ output_init_element (value, type, field, pending) ...@@ -6283,9 +6285,7 @@ output_init_element (value, type, field, pending)
&& tree_int_cst_lt (field, constructor_unfilled_index)) && tree_int_cst_lt (field, constructor_unfilled_index))
set_nonincremental_init (); set_nonincremental_init ();
add_pending_init (field, add_pending_init (field, value);
digest_init (type, value, require_constant_value,
require_constant_elements));
return; return;
} }
else if (TREE_CODE (constructor_type) == RECORD_TYPE else if (TREE_CODE (constructor_type) == RECORD_TYPE
...@@ -6311,9 +6311,7 @@ output_init_element (value, type, field, pending) ...@@ -6311,9 +6311,7 @@ output_init_element (value, type, field, pending)
} }
} }
add_pending_init (field, add_pending_init (field, value);
digest_init (type, value, require_constant_value,
require_constant_elements));
return; return;
} }
else if (TREE_CODE (constructor_type) == UNION_TYPE else if (TREE_CODE (constructor_type) == UNION_TYPE
...@@ -6332,10 +6330,7 @@ output_init_element (value, type, field, pending) ...@@ -6332,10 +6330,7 @@ output_init_element (value, type, field, pending)
if (field && TREE_CODE (field) == INTEGER_CST) if (field && TREE_CODE (field) == INTEGER_CST)
field = copy_node (field); field = copy_node (field);
constructor_elements constructor_elements
= tree_cons (field, digest_init (type, value, = tree_cons (field, value, constructor_elements);
require_constant_value,
require_constant_elements),
constructor_elements);
/* Advance the variable that indicates sequential elements output. */ /* Advance the variable that indicates sequential elements output. */
if (TREE_CODE (constructor_type) == ARRAY_TYPE) if (TREE_CODE (constructor_type) == ARRAY_TYPE)
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* gcc.c-torture/compile/20011130-1.c: New test. * gcc.c-torture/compile/20011130-1.c: New test.
* gcc.dg/noncompile/20011025-1.c: New test.
2001-12-04 Joseph S. Myers <jsm28@cam.ac.uk> 2001-12-04 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.c-torture/execute/20000722-1.x, * gcc.c-torture/execute/20000722-1.x,
......
double foo [] =
{ &bar, /* { dg-error "undeclared|is not constant|near init" } */
(void *) 0 }; /* { dg-error "incompatible types|is not constant|near init" } */
double baz [] =
{ (void *) 0 }; /* { dg-error "incompatible types|is not constant|near init" } */
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