aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1z/aggr-base9.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aggr-base9.C33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C b/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C
new file mode 100644
index 00000000000..56aa59cb64a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C
@@ -0,0 +1,33 @@
+// PR c++/89214
+// { dg-do compile { target c++17 } }
+
+struct B {
+ int c;
+};
+
+struct D : B { };
+
+void
+foo ()
+{
+ D d1 = {42};
+ D d2 = {{42}};
+
+ D d4 = D{42};
+ D d5 = D{{42}};
+
+ D d7 = {D{42}};
+ D d8 = {D{{42}}};
+
+ D d10 = {{D{42}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+ D d11 = {{D{{42}}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+
+ D dd1{42};
+ D dd2{{42}};
+
+ D dd7{D{42}};
+ D dd8{D{{42}}};
+
+ D dd10{{D{42}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+ D dd11{{D{{42}}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+}