Commit cf9ad9a7 by Mark Mitchell Committed by Mark Mitchell

re PR c++/11852 (ICE: g++ with bad struct initializer.)

	PR c++/11852
	* varasm.c (initializer_constant_valid_p): Correct logic for
	CONSTRUCTORs.

	PR c++/11852
	* g++.dg/init/struct1.C: New test.

From-SVN: r71187
parent 6ef0aa7b
2003-09-07 Mark Mitchell <mark@codesourcery.com>
PR c++/11852
* varasm.c (initializer_constant_valid_p): Correct logic for
CONSTRUCTORs.
2003-09-07 Roger Sayle <roger@eyesopen.com> 2003-09-07 Roger Sayle <roger@eyesopen.com>
* expr.c (expand_operands): New function to expand an operand pair. * expr.c (expand_operands): New function to expand an operand pair.
......
2003-09-07 Mark Mitchell <mark@codesourcery.com> 2003-09-07 Mark Mitchell <mark@codesourcery.com>
PR c++/11852
* g++.dg/init/struct1.C: New test.
2003-09-07 Mark Mitchell <mark@codesourcery.com>
PR c++/12181 PR c++/12181
* g++.dg/expr/comma1.C: New test. * g++.dg/expr/comma1.C: New test.
......
struct bug {
const char *name;
unsigned long type;
};
struct bug s = { 0, (unsigned long) &s | 1 };
...@@ -3476,11 +3476,27 @@ initializer_constant_valid_p (tree value, tree endtype) ...@@ -3476,11 +3476,27 @@ initializer_constant_valid_p (tree value, tree endtype)
|| TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE) || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE)
&& TREE_CONSTANT (value) && TREE_CONSTANT (value)
&& CONSTRUCTOR_ELTS (value)) && CONSTRUCTOR_ELTS (value))
return {
initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)), tree elt;
endtype); bool absolute = true;
for (elt = CONSTRUCTOR_ELTS (value); elt; elt = TREE_CHAIN (elt))
{
tree reloc;
value = TREE_VALUE (elt);
reloc = initializer_constant_valid_p (value, TREE_TYPE (value));
if (!reloc)
return NULL_TREE;
if (reloc != null_pointer_node)
absolute = false;
}
/* For a non-absolute relocation, there is no single
variable that can be "the variable that determines the
relocation." */
return absolute ? null_pointer_node : error_mark_node;
}
return TREE_STATIC (value) ? null_pointer_node : 0; return TREE_STATIC (value) ? null_pointer_node : NULL_TREE;
case INTEGER_CST: case INTEGER_CST:
case VECTOR_CST: case VECTOR_CST:
......
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