PR c++/67054 - Inherited ctor with non-default-constructible members
authorLeonid Koppel <lkoppel@uwaterloo.ca>
Wed, 26 Jul 2017 17:39:26 +0000 (17:39 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 26 Jul 2017 17:39:26 +0000 (13:39 -0400)
        PR c++/67054 - Inherited ctor with non-default-constructible members
        * method.c (walk_field_subobs) Consider member initializers (NSDMIs)
when deducing an inheriting constructor.

From-SVN: r250583

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/g++.dg/cpp0x/inh-ctor29.C [new file with mode: 0644]

index d65dc55f6829a0f890b69c8c2eb01a21674a2956..b2df1eff89662187f430964871bb0af9f697a0db 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-26  Leonid Koppel  <lkoppel@uwaterloo.ca>
+
+        PR c++/67054 - Inherited ctor with non-default-constructible members
+        * method.c (walk_field_subobs) Consider member initializers (NSDMIs)
+       when deducing an inheriting constructor.
+
 2017-07-21  Nathan Sidwell  <nathan@acm.org>
 
        * search.c (lookup_conversion_operator): Return overloads.
index cca1b14691720fc6b3e64a79cb944bc982fd49d0..8b07f526473288acaea6c71c4dd0da137a987d65 100644 (file)
@@ -1342,7 +1342,7 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
          if (bad && deleted_p)
            *deleted_p = true;
        }
-      else if (sfk == sfk_constructor)
+      else if (sfk == sfk_constructor || sfk == sfk_inheriting_constructor)
        {
          bool bad;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor29.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor29.C
new file mode 100644 (file)
index 0000000..8e31f73
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/67054
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  A(int) {}
+};
+
+struct C
+{
+  C(int) {}
+};
+
+struct B : A
+{
+  using A::A;
+  C c = 42;
+};
+
+int main()
+{
+  B b = 24;
+}