]> gcc.gnu.org Git - gcc.git/commitdiff
PR c++/70468 - ICE with constructor delegation via typedef.
authorJason Merrill <jason@redhat.com>
Fri, 23 Feb 2018 13:32:41 +0000 (08:32 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 23 Feb 2018 13:32:41 +0000 (08:32 -0500)
* pt.c (tsubst_initializer_list): Check for other mem-initializers
with constructor delegation.

From-SVN: r257931

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/dc9.C [new file with mode: 0644]

index 79b7f00644dc2e9613919d47162e68c2fcde1808..58710a9178735e77355992699337c4866063a9aa 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/70468 - ICE with constructor delegation via typedef.
+       * pt.c (tsubst_initializer_list): Check for other mem-initializers
+       with constructor delegation.
+
 2018-02-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/84424 - ICE with constexpr and __builtin_shuffle.
index bc03f0e818e954ac42862bf0035139bade3d0849..85d1adbbe3c3f495a97fe4bfaba496d5a1561765 100644 (file)
@@ -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);
diff --git a/gcc/testsuite/g++.dg/cpp0x/dc9.C b/gcc/testsuite/g++.dg/cpp0x/dc9.C
new file mode 100644 (file)
index 0000000..b87f5ce
--- /dev/null
@@ -0,0 +1,30 @@
+// PR c++/70468
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -w }
+
+struct S {}; 
+
+template < typename = S > 
+class A 
+{
+public:
+  A () : f0 (), f1 () {}       // { dg-error "" }
+
+private:
+  typedef A<> f0; 
+  int f1;
+};
+
+template < typename = S, typename = S > 
+class B
+{
+}; 
+
+template < typename T1, typename T2 > 
+B < T1, T2 > &operator<< (B < T1, T2 >&, const int) 
+{
+  A<> (); 
+}
+
+template 
+B < S, S > &operator<< (B < S, S >&, const int);
This page took 0.124817 seconds and 5 git commands to generate.