libstdcxx_is_pod_hack.cpp revision d295970adc93ed4035d18df23673c2a72d124cc8
1// RUN: %clang_cc1 -fsyntax-only %s
2
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.
8
9template<typename T>
10struct __is_pod {
11  __is_pod() {}
12};
13
14__is_pod<int> ipi;
15
16// Ditto for __is_same.
17template<typename T>
18struct __is_same {
19};
20
21__is_same<int> isi;
22
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++.
26struct test_is_signed {
27  static const bool __is_signed = true;
28};
29
30bool check_signed = test_is_signed::__is_signed;
31
32template<bool B> struct must_be_true {};
33template<> struct must_be_true<false>;
34
35void foo() {
36  bool b = __is_pod(int);
37  must_be_true<__is_pod(int)> mbt;
38}
39#if !__has_feature(is_pod)
40#  error __is_pod should still be available.
41#endif
42