| 1 |
// { dg-do run { target c++11 } } |
| 2 |
|
| 3 |
extern "C" void abort (); |
| 4 |
|
| 5 |
template <int N> |
| 6 |
void |
| 7 |
foo () |
| 8 |
{ |
| 9 |
enum E { E1 } e = E1; |
| 10 |
struct S { int s; } s = { 0 }; |
| 11 |
union U { int u; } u = { 0 }; |
| 12 |
int a[2] = { 0, 0 }; |
| 13 |
bool b = false; |
| 14 |
const char *p = (const char *) 0; |
| 15 |
float f = 0.0; |
| 16 |
_Complex double c = 0.0; |
| 17 |
struct T { void foo (); }; |
| 18 |
int &r = a[0]; |
| 19 |
int S::*q = &S::s; |
| 20 |
static_assert (__builtin_classify_type (void) == 0, ""); |
| 21 |
static_assert (__builtin_classify_type (int) == 1, ""); |
| 22 |
static_assert (__builtin_classify_type (enum E) == 3, ""); |
| 23 |
static_assert (__builtin_classify_type (bool) == 4, ""); |
| 24 |
static_assert (__builtin_classify_type (const char *) == 5, ""); |
| 25 |
static_assert (__builtin_classify_type (int &) == 6, ""); |
| 26 |
static_assert (__builtin_classify_type (int &&) == 6, ""); |
| 27 |
static_assert (__builtin_classify_type (int S::*) == 7, ""); |
| 28 |
static_assert (__builtin_classify_type (float) == 8, ""); |
| 29 |
static_assert (__builtin_classify_type (_Complex double) == 9, ""); |
| 30 |
static_assert (__builtin_classify_type (int (int, int)) == 10, ""); |
| 31 |
static_assert (__builtin_classify_type (struct S) == 12, ""); |
| 32 |
static_assert (__builtin_classify_type (union U) == 13, ""); |
| 33 |
static_assert (__builtin_classify_type (int [2]) == 14, ""); |
| 34 |
static_assert (__builtin_classify_type (__typeof__ (a[0])) == 1, ""); |
| 35 |
static_assert (__builtin_classify_type (__typeof__ (e)) == 3, ""); |
| 36 |
static_assert (__builtin_classify_type (__typeof__ (b)) == 4, ""); |
| 37 |
static_assert (__builtin_classify_type (__typeof__ (p)) == 5, ""); |
| 38 |
static_assert (__builtin_classify_type (decltype (r)) == 6, ""); |
| 39 |
static_assert (__builtin_classify_type (__typeof__ (q)) == 7, ""); |
| 40 |
static_assert (__builtin_classify_type (__typeof__ (f)) == 8, ""); |
| 41 |
static_assert (__builtin_classify_type (__typeof__ (c)) == 9, ""); |
| 42 |
static_assert (__builtin_classify_type (__typeof__ (abort)) == 10, ""); |
| 43 |
static_assert (__builtin_classify_type (__typeof__ (s)) == 12, ""); |
| 44 |
static_assert (__builtin_classify_type (__typeof__ (u)) == 13, ""); |
| 45 |
static_assert (__builtin_classify_type (__typeof__ (a)) == 14, ""); |
| 46 |
if (__builtin_classify_type (a[0]) != 1) |
| 47 |
abort (); |
| 48 |
if (__builtin_classify_type (e) != 3) |
| 49 |
abort (); |
| 50 |
if (__builtin_classify_type (b) != 4) |
| 51 |
abort (); |
| 52 |
if (__builtin_classify_type (p) != 5) |
| 53 |
abort (); |
| 54 |
if (__builtin_classify_type (r) != 1) |
| 55 |
abort (); |
| 56 |
if (__builtin_classify_type (q) != 7) |
| 57 |
abort (); |
| 58 |
if (__builtin_classify_type (f) != 8) |
| 59 |
abort (); |
| 60 |
if (__builtin_classify_type (c) != 9) |
| 61 |
abort (); |
| 62 |
if (__builtin_classify_type (abort) != 5) |
| 63 |
abort (); |
| 64 |
if (__builtin_classify_type (s) != 12) |
| 65 |
abort (); |
| 66 |
if (__builtin_classify_type (u) != 13) |
| 67 |
abort (); |
| 68 |
if (__builtin_classify_type (a) != 5) |
| 69 |
abort (); |
| 70 |
} |
| 71 |
|
| 72 |
template <typename V, typename I, typename E, typename B, typename P, |
| 73 |
typename R1, typename R2, typename PM, typename F, |
| 74 |
typename C, typename FN, typename S, typename U, typename A> |
| 75 |
void |
| 76 |
bar () |
| 77 |
{ |
| 78 |
E e = (E) 0; |
| 79 |
S s = { 0 }; |
| 80 |
U u = { 0 }; |
| 81 |
A a = { 0, 0 }; |
| 82 |
B b = false; |
| 83 |
P p = (P) 0; |
| 84 |
F f = 0.0; |
| 85 |
C c = 0.0; |
| 86 |
R1 r = a[0]; |
| 87 |
PM q = &S::s; |
| 88 |
static_assert (__builtin_classify_type (V) == 0, ""); |
| 89 |
static_assert (__builtin_classify_type (I) == 1, ""); |
| 90 |
static_assert (__builtin_classify_type (E) == 3, ""); |
| 91 |
static_assert (__builtin_classify_type (B) == 4, ""); |
| 92 |
static_assert (__builtin_classify_type (P) == 5, ""); |
| 93 |
static_assert (__builtin_classify_type (R1) == 6, ""); |
| 94 |
static_assert (__builtin_classify_type (R2) == 6, ""); |
| 95 |
static_assert (__builtin_classify_type (PM) == 7, ""); |
| 96 |
static_assert (__builtin_classify_type (F) == 8, ""); |
| 97 |
static_assert (__builtin_classify_type (C) == 9, ""); |
| 98 |
static_assert (__builtin_classify_type (FN) == 10, ""); |
| 99 |
static_assert (__builtin_classify_type (S) == 12, ""); |
| 100 |
static_assert (__builtin_classify_type (U) == 13, ""); |
| 101 |
static_assert (__builtin_classify_type (A) == 14, ""); |
| 102 |
static_assert (__builtin_classify_type (__typeof__ (a[0])) == 1, ""); |
| 103 |
static_assert (__builtin_classify_type (__typeof__ (e)) == 3, ""); |
| 104 |
static_assert (__builtin_classify_type (__typeof__ (b)) == 4, ""); |
| 105 |
static_assert (__builtin_classify_type (__typeof__ (p)) == 5, ""); |
| 106 |
static_assert (__builtin_classify_type (decltype (r)) == 6, ""); |
| 107 |
static_assert (__builtin_classify_type (__typeof__ (q)) == 7, ""); |
| 108 |
static_assert (__builtin_classify_type (__typeof__ (f)) == 8, ""); |
| 109 |
static_assert (__builtin_classify_type (__typeof__ (c)) == 9, ""); |
| 110 |
static_assert (__builtin_classify_type (__typeof__ (abort)) == 10, ""); |
| 111 |
static_assert (__builtin_classify_type (__typeof__ (s)) == 12, ""); |
| 112 |
static_assert (__builtin_classify_type (__typeof__ (u)) == 13, ""); |
| 113 |
static_assert (__builtin_classify_type (__typeof__ (a)) == 14, ""); |
| 114 |
if (__builtin_classify_type (a[0]) != 1) |
| 115 |
abort (); |
| 116 |
if (__builtin_classify_type (e) != 3) |
| 117 |
abort (); |
| 118 |
if (__builtin_classify_type (b) != 4) |
| 119 |
abort (); |
| 120 |
if (__builtin_classify_type (p) != 5) |
| 121 |
abort (); |
| 122 |
if (__builtin_classify_type (r) != 1) |
| 123 |
abort (); |
| 124 |
if (__builtin_classify_type (q) != 7) |
| 125 |
abort (); |
| 126 |
if (__builtin_classify_type (f) != 8) |
| 127 |
abort (); |
| 128 |
if (__builtin_classify_type (c) != 9) |
| 129 |
abort (); |
| 130 |
if (__builtin_classify_type (abort) != 5) |
| 131 |
abort (); |
| 132 |
if (__builtin_classify_type (s) != 12) |
| 133 |
abort (); |
| 134 |
if (__builtin_classify_type (u) != 13) |
| 135 |
abort (); |
| 136 |
if (__builtin_classify_type (a) != 5) |
| 137 |
abort (); |
| 138 |
} |
| 139 |
|
| 140 |
int |
| 141 |
main () |
| 142 |
{ |
| 143 |
enum E { E1 }; |
| 144 |
struct S { int s; }; |
| 145 |
union U { int u; }; |
| 146 |
foo <0> (); |
| 147 |
bar <void, int, E, bool, const char *, int &, int &&, int S::*, |
| 148 |
float, _Complex double, int (int, int), S, U, int [2]> (); |
| 149 |
} |