diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-29 09:52:51 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-29 09:52:51 +0000 |
commit | 581af848ad9bbb298ab10f264c7fd83f665aa1a9 (patch) | |
tree | 957d80217ed43186278a3c6bc7ccb26b5ef4b738 /gcc/cp/decl2.c | |
parent | dde76aebcc84ec6fbb7204e8f47abfb468794dae (diff) | |
download | gcc-581af848ad9bbb298ab10f264c7fd83f665aa1a9.tar.gz |
cp:
PR c++/5132
* typeck2.c (digest_init): Make sure non-array core type is
instantiated.
* decl2.c (reparse_absdcl_as_casts): Just store the type in the
constructor, rather than build a new one.
(build_expr_from_tree, CONSTRUCTOR case): Be careful with the
PURPOSE of constructor elts.
testsuite:
* g++.dg/template/ctor1.C: Add instantiation.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49314 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 67559b92299..95f142731a6 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3620,7 +3620,7 @@ reparse_absdcl_as_casts (decl, expr) decl = TREE_OPERAND (decl, 0); if (processing_template_decl) - expr = build_min (CONSTRUCTOR, type, decl, CONSTRUCTOR_ELTS (expr)); + TREE_TYPE (expr) = type; else { expr = digest_init (type, expr, (tree *) 0); @@ -3938,17 +3938,35 @@ build_expr_from_tree (t) case CONSTRUCTOR: { tree r; + tree elts; + tree type = TREE_TYPE (t); + bool purpose_p; /* digest_init will do the wrong thing if we let it. */ - if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t))) + if (type && TYPE_PTRMEMFUNC_P (type)) return t; - r = build_nt (CONSTRUCTOR, NULL_TREE, - build_expr_from_tree (CONSTRUCTOR_ELTS (t))); + r = NULL_TREE; + /* We do not want to process the purpose of aggregate + initializers as they are identifier nodes which will be + looked up by digest_init. */ + purpose_p = !(type && IS_AGGR_TYPE (type)); + for (elts = CONSTRUCTOR_ELTS (t); elts; elts = TREE_CHAIN (elts)) + { + tree purpose = TREE_PURPOSE (elts); + tree value = TREE_VALUE (elts); + + if (purpose && purpose_p) + purpose = build_expr_from_tree (purpose); + value = build_expr_from_tree (value); + r = tree_cons (purpose, value, r); + } + + r = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (r)); TREE_HAS_CONSTRUCTOR (r) = TREE_HAS_CONSTRUCTOR (t); - if (TREE_TYPE (t)) - return digest_init (TREE_TYPE (t), r, 0); + if (type) + return digest_init (type, r, 0); return r; } |