Commit 125f2a50 by Mark Mitchell Committed by Mark Mitchell

re PR c++/23171 (ICE on pointer initialization with C99 initializer)

	PR c++/23171
	* varasm.c (initializer_constant_valid_p): An ADDR_EXPR of a
	CONSTRUCTOR is invalid.

	PR c++/23171
	* g++.dg/opt/init1.C: New test.

From-SVN: r109035
parent 097d5d18
2005-12-24 Mark Mitchell <mark@codesourcery.com>
PR c++/23171
* varasm.c (initializer_constant_valid_p): An ADDR_EXPR of a
CONSTRUCTOR is invalid.
2005-12-23 Daniel Berlin <dberlin@dberlin.org> 2005-12-23 Daniel Berlin <dberlin@dberlin.org>
* tree-pass.h (pass_eliminate_useless_stores): Remove. * tree-pass.h (pass_eliminate_useless_stores): Remove.
......
2005-12-24 Mark Mitchell <mark@codesourcery.com>
PR c++/23171
* g++.dg/opt/init1.C: New test.
2005-12-23 Mark Mitchell <mark@codesourcery.com> 2005-12-23 Mark Mitchell <mark@codesourcery.com>
PR c++/24671 PR c++/24671
// PR c++/23171
// { dg-options "-O" }
int *p = (int*)(int[1]){0};
...@@ -3477,18 +3477,24 @@ initializer_constant_valid_p (tree value, tree endtype) ...@@ -3477,18 +3477,24 @@ initializer_constant_valid_p (tree value, tree endtype)
case ADDR_EXPR: case ADDR_EXPR:
case FDESC_EXPR: case FDESC_EXPR:
value = staticp (TREE_OPERAND (value, 0)); value = staticp (TREE_OPERAND (value, 0));
/* "&(*a).f" is like unto pointer arithmetic. If "a" turns out to if (value)
be a constant, this is old-skool offsetof-like nonsense. */ {
if (value /* "&(*a).f" is like unto pointer arithmetic. If "a" turns out to
&& TREE_CODE (value) == INDIRECT_REF be a constant, this is old-skool offsetof-like nonsense. */
&& TREE_CONSTANT (TREE_OPERAND (value, 0))) if (TREE_CODE (value) == INDIRECT_REF
return null_pointer_node; && TREE_CONSTANT (TREE_OPERAND (value, 0)))
/* Taking the address of a nested function involves a trampoline. */ return null_pointer_node;
if (value /* Taking the address of a nested function involves a trampoline. */
&& TREE_CODE (value) == FUNCTION_DECL if (TREE_CODE (value) == FUNCTION_DECL
&& ((decl_function_context (value) && !DECL_NO_STATIC_CHAIN (value)) && ((decl_function_context (value)
|| DECL_DLLIMPORT_P (value))) && !DECL_NO_STATIC_CHAIN (value))
return NULL_TREE; || DECL_DLLIMPORT_P (value)))
return NULL_TREE;
/* "&{...}" requires a temporary to hold the constructed
object. */
if (TREE_CODE (value) == CONSTRUCTOR)
return NULL_TREE;
}
return value; return value;
case VIEW_CONVERT_EXPR: case VIEW_CONVERT_EXPR:
......
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