summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C b/gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C
new file mode 100644
index 00000000000..02ec58a3e8e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C
@@ -0,0 +1,33 @@
+// Testcase from P0136
+// { dg-do compile { target c++11 } }
+
+struct B1 {
+ template <class... Ts>
+ B1(int, Ts...) { }
+};
+
+struct B2 {
+ B2(double) { }
+};
+
+int get();
+
+struct D1 : B1 { // { dg-message "B1::B1" }
+ using B1::B1; // inherits B1(int, ...)
+ int x;
+ int y = get();
+};
+
+void test() {
+ D1 d(2, 3, 4); // OK: B1 is initialized by calling B1(2, 3, 4),
+ // then d.x is default-initialized (no initialization is performed),
+ // then d.y is initialized by calling get()
+ D1 e; // { dg-error "" } D1 has a deleted default constructor
+}
+
+struct D2 : B2 {
+ using B2::B2; // { dg-message "B1::B1" }
+ B1 b;
+};
+
+D2 f(1.0); // { dg-error "" } B1 has no default constructor