Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only %s |
Douglas Gregor | b117a60 | 2009-09-04 05:53:02 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | c53d0d7 | 2010-04-08 18:16:15 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | b117a60 | 2009-09-04 05:53:02 +0000 | [diff] [blame] | 9 | template<typename T> |
| 10 | struct __is_pod { |
Douglas Gregor | d295970 | 2012-08-30 20:04:43 +0000 | [diff] [blame] | 11 | __is_pod() {} |
Douglas Gregor | b117a60 | 2009-09-04 05:53:02 +0000 | [diff] [blame] | 12 | }; |
| 13 | |
| 14 | __is_pod<int> ipi; |
Douglas Gregor | bfad915 | 2011-04-28 15:48:45 +0000 | [diff] [blame] | 15 | |
Douglas Gregor | 877222e | 2011-04-29 01:38:03 +0000 | [diff] [blame] | 16 | // Ditto for __is_same. |
| 17 | template<typename T> |
| 18 | struct __is_same { |
| 19 | }; |
| 20 | |
Douglas Gregor | 2cc702e | 2011-04-29 01:50:40 +0000 | [diff] [blame] | 21 | __is_same<int> isi; |
Douglas Gregor | 877222e | 2011-04-29 01:38:03 +0000 | [diff] [blame] | 22 | |
Douglas Gregor | bfad915 | 2011-04-28 15:48:45 +0000 | [diff] [blame] | 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; |
| 28 | }; |
| 29 | |
| 30 | bool check_signed = test_is_signed::__is_signed; |
Douglas Gregor | 6887614 | 2011-07-30 07:01:49 +0000 | [diff] [blame] | 31 | |
Douglas Gregor | d295970 | 2012-08-30 20:04:43 +0000 | [diff] [blame] | 32 | template<bool B> struct must_be_true {}; |
| 33 | template<> struct must_be_true<false>; |
| 34 | |
| 35 | void 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. |
Douglas Gregor | 6887614 | 2011-07-30 07:01:49 +0000 | [diff] [blame] | 41 | #endif |