aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-12-24 08:51:05 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-12-24 08:51:05 +0000
commit125f2a50c9e0c994dc2642c41dc597e03618c3cc (patch)
tree4b42632a639078d9ef8f1062fdfbd875b99f3576 /gcc/varasm.c
parent097d5d18f0c4993b69e79765f3ea44d7bc1d4c53 (diff)
downloadgcc-125f2a50c9e0c994dc2642c41dc597e03618c3cc.zip
gcc-125f2a50c9e0c994dc2642c41dc597e03618c3cc.tar.gz
gcc-125f2a50c9e0c994dc2642c41dc597e03618c3cc.tar.bz2
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
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index f304bb7..f39b07c 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -3477,18 +3477,24 @@ initializer_constant_valid_p (tree value, tree endtype)
case ADDR_EXPR:
case FDESC_EXPR:
value = staticp (TREE_OPERAND (value, 0));
- /* "&(*a).f" is like unto pointer arithmetic. If "a" turns out to
- be a constant, this is old-skool offsetof-like nonsense. */
- if (value
- && TREE_CODE (value) == INDIRECT_REF
- && TREE_CONSTANT (TREE_OPERAND (value, 0)))
- return null_pointer_node;
- /* Taking the address of a nested function involves a trampoline. */
- if (value
- && TREE_CODE (value) == FUNCTION_DECL
- && ((decl_function_context (value) && !DECL_NO_STATIC_CHAIN (value))
- || DECL_DLLIMPORT_P (value)))
- return NULL_TREE;
+ if (value)
+ {
+ /* "&(*a).f" is like unto pointer arithmetic. If "a" turns out to
+ be a constant, this is old-skool offsetof-like nonsense. */
+ if (TREE_CODE (value) == INDIRECT_REF
+ && TREE_CONSTANT (TREE_OPERAND (value, 0)))
+ return null_pointer_node;
+ /* Taking the address of a nested function involves a trampoline. */
+ if (TREE_CODE (value) == FUNCTION_DECL
+ && ((decl_function_context (value)
+ && !DECL_NO_STATIC_CHAIN (value))
+ || 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;
case VIEW_CONVERT_EXPR: