diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-07 23:48:33 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-07 23:48:33 +0000 |
commit | 267d45d9f16fa4d967f40f0a2a424a49848c0b8b (patch) | |
tree | 4f5bca36819c0c2c172a2b3ec1aa934de5c312d6 /gcc/varasm.c | |
parent | 16a521b226727fc5e7124ff5b444f7c9513f6e74 (diff) | |
download | gcc-267d45d9f16fa4d967f40f0a2a424a49848c0b8b.tar.gz |
PR c++/11852
* varasm.c (initializer_constant_valid_p): Correct logic for
CONSTRUCTORs.
PR c++/11852
* g++.dg/init/struct1.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71187 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index d327cb2d8c2..84fbf259baf 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3476,11 +3476,27 @@ initializer_constant_valid_p (tree value, tree endtype) || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE) && TREE_CONSTANT (value) && CONSTRUCTOR_ELTS (value)) - return - initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)), - endtype); + { + tree elt; + 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 VECTOR_CST: |