[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / libstdcxx_is_pod_hack.cpp
bloba853a484707df3ad5e605e6a27b62a38787f32c4
1 // RUN: %clang_cc1 -fsyntax-only -verify %std_cxx98-14 %s
3 // This is a test for an egregious hack in Clang that works around
4 // issues with GCC's evolution. libstdc++ 4.2.x uses __is_pod as an
5 // identifier (to declare a struct template like the one below), while
6 // GCC 4.3 and newer make __is_pod a keyword. Clang treats __is_pod as
7 // a keyword *unless* it is introduced following the struct keyword.
9 template<typename T>
10 struct __is_pod { // expected-warning {{keyword '__is_pod' will be made available as an identifier}}
11 __is_pod() {}
14 __is_pod<int> ipi;
16 // Ditto for __is_same.
17 template<typename T>
18 struct __is_same { // expected-warning {{keyword '__is_same' will be made available as an identifier}}
21 __is_same<int> isi;
23 // Another, similar egregious hack for __is_signed, which is a type
24 // trait in Embarcadero's compiler but is used as an identifier in
25 // libstdc++.
26 struct test_is_signed {
27 static const bool __is_signed = true; // expected-warning {{keyword '__is_signed' will be made available as an identifier}}
30 bool check_signed = test_is_signed::__is_signed;
32 template<bool B> struct must_be_true {};
33 template<> struct must_be_true<false>;
35 void foo() {
36 bool b = __is_pod(int);
37 must_be_true<__is_pod(int)> mbt;
40 // expected-warning@+1 {{declaration does not declare anything}}
41 struct // expected-error {{declaration of anonymous struct must be a definition}}
42 #pragma pack(pop)
43 S {
46 #if !__has_feature(is_pod)
47 # error __is_pod should still be available.
48 #endif