Commit 7efc22ea by Jason Merrill Committed by Jason Merrill

re PR c++/35116 (Fail to compile valid code)

        PR c++/35116
        * tree.c (build_target_expr_with_type): Handle void initializer.
        (bot_manip): Remap slot before recursing.

From-SVN: r132197
parent e37f6a49
2008-02-08 Jason Merrill <jason@redhat.com>
PR c++/35116
* tree.c (build_target_expr_with_type): Handle void initializer.
(bot_manip): Remap slot before recursing.
2008-02-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2008-02-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR other/35107 PR other/35107
......
...@@ -415,10 +415,12 @@ build_target_expr_with_type (tree init, tree type) ...@@ -415,10 +415,12 @@ build_target_expr_with_type (tree init, tree type)
if (TREE_CODE (init) == TARGET_EXPR) if (TREE_CODE (init) == TARGET_EXPR)
return init; return init;
else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_INIT_REF (type) else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_INIT_REF (type)
&& !VOID_TYPE_P (TREE_TYPE (init))
&& TREE_CODE (init) != COND_EXPR && TREE_CODE (init) != COND_EXPR
&& TREE_CODE (init) != CONSTRUCTOR && TREE_CODE (init) != CONSTRUCTOR
&& TREE_CODE (init) != VA_ARG_EXPR) && TREE_CODE (init) != VA_ARG_EXPR)
/* We need to build up a copy constructor call. COND_EXPR is a special /* We need to build up a copy constructor call. A void initializer
means we're being called from bot_manip. COND_EXPR is a special
case because we already have copies on the arms and we don't want case because we already have copies on the arms and we don't want
another one here. A CONSTRUCTOR is aggregate initialization, which another one here. A CONSTRUCTOR is aggregate initialization, which
is handled separately. A VA_ARG_EXPR is magic creation of an is handled separately. A VA_ARG_EXPR is magic creation of an
...@@ -1468,17 +1470,17 @@ bot_manip (tree* tp, int* walk_subtrees, void* data) ...@@ -1468,17 +1470,17 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
tree u; tree u;
if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR) if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
u = build_cplus_new u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1));
(TREE_TYPE (t), break_out_target_exprs (TREE_OPERAND (t, 1)));
else else
u = build_target_expr_with_type u = build_target_expr_with_type (TREE_OPERAND (t, 1), TREE_TYPE (t));
(break_out_target_exprs (TREE_OPERAND (t, 1)), TREE_TYPE (t));
/* Map the old variable to the new one. */ /* Map the old variable to the new one. */
splay_tree_insert (target_remap, splay_tree_insert (target_remap,
(splay_tree_key) TREE_OPERAND (t, 0), (splay_tree_key) TREE_OPERAND (t, 0),
(splay_tree_value) TREE_OPERAND (u, 0)); (splay_tree_value) TREE_OPERAND (u, 0));
TREE_OPERAND (u, 1) = break_out_target_exprs (TREE_OPERAND (u, 1));
/* Replace the old expression with the new version. */ /* Replace the old expression with the new version. */
*tp = u; *tp = u;
/* We don't have to go below this point; the recursive call to /* We don't have to go below this point; the recursive call to
......
// PR c++/35116
// Test that break_out_target_exprs works properly with complex
// value-initialization.
struct A
{
virtual void f ();
};
struct B
{
A a;
};
struct C
{
C (int, B = B());
};
void f ()
{
C c (4);
}
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