re PR c++/79143 ([new inheriting constructors] inheriting constructor fails with...
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Feb 2017 22:12:15 +0000 (23:12 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Feb 2017 22:12:15 +0000 (23:12 +0100)
PR c++/79143
* pt.c (instantiate_class_template_1): Copy CLASSTYPE_NON_AGGREGATE
from pattern to type.

* g++.dg/cpp1z/pr79143.C: New test.

Co-Authored-By: Jason Merrill <jason@redhat.com>
From-SVN: r245315

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

index caa1df91383302646323967fd3d234ab9d0ff078..f615f908f5e496bc1c6957a764e96b4e035fc322 100644 (file)
@@ -1,3 +1,10 @@
+2017-02-09  Jakub Jelinek  <jakub@redhat.com>
+           Jason Merrill  <jason@redhat.com>
+
+       PR c++/79143
+       * pt.c (instantiate_class_template_1): Copy CLASSTYPE_NON_AGGREGATE
+       from pattern to type.
+
 2017-02-09  Jason Merrill  <jason@redhat.com>
 
        PR c++/79316 - default argument in deduction guide
index 58d60160e9807eef56c63850cd203aa05622b0ca..0a4510c8ebee3c07d67050b72d9450571e2d2d30 100644 (file)
@@ -10253,6 +10253,7 @@ instantiate_class_template_1 (tree type)
   TYPE_PACKED (type) = TYPE_PACKED (pattern);
   SET_TYPE_ALIGN (type, TYPE_ALIGN (pattern));
   TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern);
+  CLASSTYPE_NON_AGGREGATE (type) = CLASSTYPE_NON_AGGREGATE (pattern);
   if (ANON_AGGR_TYPE_P (pattern))
     SET_ANON_AGGR_TYPE_P (type);
   if (CLASSTYPE_VISIBILITY_SPECIFIED (pattern))
index 599780624e43637d263fa5e41b11a8915954ab85..1030f172c6d8d2497ff48aac7a7703ff26a20d0c 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-09  Jakub Jelinek  <jakub@redhat.com>
+           Jason Merrill  <jason@redhat.com>
+
+       PR c++/79143
+       * g++.dg/cpp1z/pr79143.C: New test.
+
 2017-02-09  Jan Hubicka  <hubicka@ucw.cz>
 
        * gcc.dg/loop-unswitch-2.c: Update testcase.
diff --git a/gcc/testsuite/g++.dg/cpp1z/pr79143.C b/gcc/testsuite/g++.dg/cpp1z/pr79143.C
new file mode 100644 (file)
index 0000000..baeaa48
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/79143
+// { dg-do compile }
+// { dg-options "-std=c++1z" }
+
+struct base {
+  base (int, int) {}
+};
+
+template<class>
+struct derived : base {
+  using base::base;
+};
+
+template<class>
+struct derived2 : base {
+  derived2 (int x, int y) : base (x, y) {}
+};
+
+int
+main ()
+{
+  base (13, 42);
+  derived<int> (13, 42);
+  derived2<int> (13, 42);
+  base{13, 42};
+  derived<int>{13, 42}; // { dg-bogus "too many initializers" }
+  derived2<int>{13, 42};
+}