Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / type-traits-ms-extensions.cpp
blob2f4e81498090dc60ea94cd34f398f4147b6f5568
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s -Wno-c++17-extensions
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s -Wno-c++17-extensions
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
4 // RUN: %clang_cc1 -x c -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu11 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
6 #ifdef __cplusplus
8 // expected-no-diagnostics
10 using Int = int;
12 struct NonPOD { NonPOD(int); };
13 enum Enum { EV };
14 struct POD { Enum e; int i; float f; NonPOD* p; };
15 struct Derives : POD {};
16 using ClassType = Derives;
18 union Union { int i; float f; };
20 struct HasAnonymousUnion {
21 union {
22 int i;
23 float f;
27 struct FinalClass final {
30 template<typename T>
31 struct PotentiallyFinal { };
33 template<typename T>
34 struct PotentiallyFinal<T*> final { };
36 template<>
37 struct PotentiallyFinal<int> final { };
39 struct SealedClass sealed {
42 template<typename T>
43 struct PotentiallySealed { };
45 template<typename T>
46 struct PotentiallySealed<T*> sealed { };
48 template<>
49 struct PotentiallySealed<int> sealed { };
51 void is_final() {
52 static_assert(__is_final(SealedClass));
53 static_assert(__is_final(PotentiallySealed<float*>));
54 static_assert(__is_final(PotentiallySealed<int>));
56 static_assert(!__is_final(PotentiallyFinal<float>));
57 static_assert(!__is_final(PotentiallySealed<float>));
60 void is_sealed()
62 static_assert(__is_sealed(SealedClass));
63 static_assert(__is_sealed(PotentiallySealed<float*>));
64 static_assert(__is_sealed(PotentiallySealed<int>));
65 static_assert(__is_sealed(FinalClass));
66 static_assert(__is_sealed(PotentiallyFinal<float*>));
67 static_assert(__is_sealed(PotentiallyFinal<int>));
69 static_assert(!__is_sealed(int));
70 static_assert(!__is_sealed(Union));
71 static_assert(!__is_sealed(Int));
72 static_assert(!__is_sealed(Int[10]));
73 static_assert(!__is_sealed(Union[10]));
74 static_assert(!__is_sealed(Derives));
75 static_assert(!__is_sealed(ClassType));
76 static_assert(!__is_sealed(const void));
77 static_assert(!__is_sealed(Int[]));
78 static_assert(!__is_sealed(HasAnonymousUnion));
79 static_assert(!__is_sealed(PotentiallyFinal<float>));
80 static_assert(!__is_sealed(PotentiallySealed<float>));
82 #else
83 struct s1 {};
85 void is_destructible()
87 (void)__is_destructible(int);
88 (void)__is_destructible(struct s1);
89 (void)__is_destructible(struct s2); // expected-error{{incomplete type 'struct s2' used in type trait expression}}
90 // expected-note@-1{{}}
92 #endif