blob: 124576aa95b6d74d690d96da712d77739b3e0d7b [file] [log] [blame]
Stephan Tolksdorfded4d562014-03-27 20:23:36 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify
Anders Carlsson2b32dad2011-03-24 01:01:41 +00002
3namespace test1 {
4 struct A { ~A(); };
5 A a; // expected-warning {{declaration requires an exit-time destructor}}
6 A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
7 A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
8
9 A &d = a;
10 A &e = b[5];
11 A &f = c[5][7];
12}
13
14namespace test2 {
15void f() {
16 struct A { ~A() { } };
17
18 static A a; // expected-warning {{declaration requires an exit-time destructor}}
19 static A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
20 static A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
21
22 static A &d = a;
23 static A &e = b[5];
24 static A &f = c[5][7];
25}
Stephan Tolksdorfded4d562014-03-27 20:23:36 +000026}
Anders Carlsson2b32dad2011-03-24 01:01:41 +000027
Stephan Tolksdorfded4d562014-03-27 20:23:36 +000028namespace test3 {
29 struct A { ~A() = default; };
30 A a;
31
32 struct B { ~B(); };
33 struct C : B { ~C() = default; };
34 C c; // expected-warning {{exit-time destructor}}
35
36 class D {
37 friend struct E;
38 ~D() = default;
39 };
40 struct E : D {
41 D d;
42 ~E() = default;
43 };
44 E e;
Anders Carlsson2b32dad2011-03-24 01:01:41 +000045}