summaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index bc03f0e818e..85d1adbbe3c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -23558,6 +23558,7 @@ static tree
tsubst_initializer_list (tree t, tree argvec)
{
tree inits = NULL_TREE;
+ tree target_ctor = error_mark_node;
for (; t; t = TREE_CHAIN (t))
{
@@ -23674,6 +23675,28 @@ tsubst_initializer_list (tree t, tree argvec)
in_base_initializer = 0;
}
+ if (target_ctor != error_mark_node
+ && init != error_mark_node)
+ {
+ error ("mem-initializer for %qD follows constructor delegation",
+ decl);
+ return inits;
+ }
+ /* Look for a target constructor. */
+ if (init != error_mark_node
+ && decl && CLASS_TYPE_P (decl)
+ && same_type_p (decl, current_class_type))
+ {
+ maybe_warn_cpp0x (CPP0X_DELEGATING_CTORS);
+ if (inits)
+ {
+ error ("constructor delegation follows mem-initializer for %qD",
+ TREE_PURPOSE (inits));
+ continue;
+ }
+ target_ctor = init;
+ }
+
if (decl)
{
init = build_tree_list (decl, init);