aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/dcl.decl/dcl.init/dcl.init.aggr
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/dcl.decl/dcl.init/dcl.init.aggr')
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp13
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp23
2 files changed, 31 insertions, 5 deletions
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
index fef3692609fa..8767678362a3 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y
// An aggregate is an array or a class...
struct Aggr {
@@ -18,9 +19,6 @@ struct NonAggr1a { // expected-note 2 {{candidate constructor}}
NonAggr1a(int, int); // expected-note {{candidate constructor}}
int k;
};
-// In C++0x, 'user-provided' is only defined for special member functions, so
-// this type is considered to be an aggregate. This is considered to be
-// a language defect.
NonAggr1a na1a = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1a'}}
struct NonAggr1b {
@@ -30,10 +28,15 @@ struct NonAggr1b {
NonAggr1b na1b = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1b'}}
// no brace-or-equal-initializers for non-static data members, ...
-struct NonAggr2 { // expected-note 3 {{candidate constructor}}
+// Note, this bullet was removed in C++1y.
+struct NonAggr2 {
int m = { 123 };
};
-NonAggr2 na2 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr2'}}
+NonAggr2 na2 = { 42 };
+#ifndef CXX1Y
+// expected-error@-2 {{no matching constructor for initialization of 'NonAggr2'}}
+// expected-note@-6 3 {{candidate constructor}}
+#endif
// no private...
struct NonAggr3 { // expected-note 3 {{candidate constructor}}
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp
new file mode 100644
index 000000000000..d1fbe766d527
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++1y %s -verify
+
+// expected-no-diagnostics
+
+struct S { int a; const char *b; int c; int d = b[a]; };
+constexpr S ss = { 1, "asdf" };
+
+static_assert(ss.a == 1, "");
+static_assert(ss.b[2] == 'd', "");
+static_assert(ss.c == 0, "");
+static_assert(ss.d == 's', "");
+
+struct X { int i, j, k = 42; };
+constexpr X a[] = { 1, 2, 3, 4, 5, 6 };
+constexpr X b[2] = { { 1, 2, 3 }, { 4, 5, 6 } };
+
+constexpr bool operator==(X a, X b) {
+ return a.i == b.i && a.j == b.j && a.k == b.k;
+}
+
+static_assert(sizeof(a) == sizeof(b), "");
+static_assert(a[0] == b[0], "");
+static_assert(a[1] == b[1], "");