aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/flexible-array-test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/flexible-array-test.cpp')
-rw-r--r--test/SemaCXX/flexible-array-test.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/SemaCXX/flexible-array-test.cpp b/test/SemaCXX/flexible-array-test.cpp
index f287711eeb6a..e58f19a62eca 100644
--- a/test/SemaCXX/flexible-array-test.cpp
+++ b/test/SemaCXX/flexible-array-test.cpp
@@ -36,14 +36,20 @@ void foo()
}
struct S {
- virtual void foo();
+ virtual void foo();
};
struct X {
int blah;
- S strings[]; // expected-error {{flexible array member 'strings' of non-POD element type 'S []'}}
+ S strings[];
};
+S a, b = a;
+S f(X &x) {
+ a = b;
+ return x.strings[0];
+}
+
class A {
int s;
char c[];
@@ -71,3 +77,14 @@ struct VirtStorage : virtual StorageBase {
};
}
+
+struct NonTrivDtor { ~NonTrivDtor(); };
+// FIXME: It's not clear whether we should disallow examples like this. GCC accepts.
+struct FlexNonTrivDtor {
+ int n;
+ NonTrivDtor ntd[]; // expected-error {{flexible array member 'ntd' of type 'NonTrivDtor []' with non-trivial destruction}}
+ ~FlexNonTrivDtor() {
+ for (int i = n; i != 0; --i)
+ ntd[i-1].~NonTrivDtor();
+ }
+};