Debian Codegraph @

clang/test/SemaCXX/union-member-destructor.cpp

raw
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2
3 namespace t1 {
4 template <class T> struct VSX {
5 ~VSX() { static_assert(sizeof(T) != 4, ""); } // expected-error {{static assertion failed due to requirement 'sizeof(int) != 4':}} \
6 // expected-note {{expression evaluates to '4 != 4'}}
7 };
8 struct VS {
9 union {
10 VSX<int> _Tail;
11 };
12 ~VS() { }
13 VS(short);
14 VS();
15 };
16 VS::VS() : VS(0) { } // delegating constructors should not produce errors
17 VS::VS(short) : _Tail() { } // expected-note {{in instantiation of member function 't1::VSX<int>::~VSX' requested here}}
18 }
19
20
21 namespace t2 {
22 template <class T> struct VSX {
23 ~VSX() { static_assert(sizeof(T) != 4, ""); } // expected-error {{static assertion failed due to requirement 'sizeof(int) != 4':}} \
24 // expected-note {{expression evaluates to '4 != 4'}}
25 };
26 struct VS {
27 union {
28 struct {
29 VSX<int> _Tail;
30 };
31 };
32 ~VS() { }
33 VS(short);
34 };
35 VS::VS(short) : _Tail() { } // expected-note {{in instantiation of member function 't2::VSX<int>::~VSX' requested here}}
36 }
37
38
39 namespace t3 {
40 template <class T> struct VSX {
41 ~VSX() { static_assert(sizeof(T) != 4, ""); } // expected-error {{static assertion failed due to requirement 'sizeof(int) != 4':}} \
42 // expected-note {{expression evaluates to '4 != 4'}}
43 };
44 union VS {
45 VSX<int> _Tail;
46 ~VS() { }
47 VS(short);
48 };
49 VS::VS(short) : _Tail() { } // expected-note {{in instantiation of member function 't3::VSX<int>::~VSX' requested here}}
50 }