| 1 |
/* { dg-do run { target { c || c++11 } } } */ |
| 2 |
|
| 3 |
#if !defined(__cplusplus) && __STDC_VERSION__ <= 201710L |
| 4 |
#define static_assert _Static_assert |
| 5 |
#define bool _Bool |
| 6 |
#define false ((_Bool) 0) |
| 7 |
#endif |
| 8 |
#ifdef __cplusplus |
| 9 |
extern "C" void abort (); |
| 10 |
#else |
| 11 |
extern void abort (void); |
| 12 |
#endif |
| 13 |
|
| 14 |
int |
| 15 |
main () |
| 16 |
{ |
| 17 |
enum E { E1 } e = E1; |
| 18 |
struct S { int s; } s = { 0 }; |
| 19 |
union U { int u; } u = { 0 }; |
| 20 |
int a[2] = { 0, 0 }; |
| 21 |
bool b = false; |
| 22 |
const char *p = (const char *) 0; |
| 23 |
float f = 0.0; |
| 24 |
_Complex double c = 0.0; |
| 25 |
typedef int VI __attribute__((vector_size (4 * sizeof (int)))); |
| 26 |
typedef float VF __attribute__((vector_size (4 * sizeof (int)))); |
| 27 |
VI vi = { 0, 0, 0, 0 }; |
| 28 |
VF vf = { 0.0f, 0.0f, 0.0f, 0.0f }; |
| 29 |
#ifdef __cplusplus |
| 30 |
struct T { void foo (); }; |
| 31 |
int &r = a[0]; |
| 32 |
int S::*q = &S::s; |
| 33 |
#endif |
| 34 |
static_assert (__builtin_classify_type (void) == 0, ""); |
| 35 |
static_assert (__builtin_classify_type (int) == 1, ""); |
| 36 |
static_assert (__builtin_classify_type (enum E) == 3, ""); |
| 37 |
static_assert (__builtin_classify_type (bool) == 4, ""); |
| 38 |
static_assert (__builtin_classify_type (const char *) == 5, ""); |
| 39 |
#ifdef __cplusplus |
| 40 |
static_assert (__builtin_classify_type (int &) == 6, ""); |
| 41 |
static_assert (__builtin_classify_type (int &&) == 6, ""); |
| 42 |
static_assert (__builtin_classify_type (int S::*) == 7, ""); |
| 43 |
#endif |
| 44 |
static_assert (__builtin_classify_type (float) == 8, ""); |
| 45 |
static_assert (__builtin_classify_type (_Complex double) == 9, ""); |
| 46 |
static_assert (__builtin_classify_type (int (int, int)) == 10, ""); |
| 47 |
static_assert (__builtin_classify_type (struct S) == 12, ""); |
| 48 |
static_assert (__builtin_classify_type (union U) == 13, ""); |
| 49 |
static_assert (__builtin_classify_type (int [2]) == 14, ""); |
| 50 |
static_assert (__builtin_classify_type (VI) == 19, ""); |
| 51 |
static_assert (__builtin_classify_type (VF) == 19, ""); |
| 52 |
static_assert (__builtin_classify_type (__typeof__ (a[0])) == 1, ""); |
| 53 |
static_assert (__builtin_classify_type (__typeof__ (e)) == 3, ""); |
| 54 |
static_assert (__builtin_classify_type (__typeof__ (b)) == 4, ""); |
| 55 |
static_assert (__builtin_classify_type (__typeof__ (p)) == 5, ""); |
| 56 |
#ifdef __cplusplus |
| 57 |
static_assert (__builtin_classify_type (decltype (r)) == 6, ""); |
| 58 |
static_assert (__builtin_classify_type (__typeof__ (q)) == 7, ""); |
| 59 |
#endif |
| 60 |
static_assert (__builtin_classify_type (__typeof__ (f)) == 8, ""); |
| 61 |
static_assert (__builtin_classify_type (__typeof__ (c)) == 9, ""); |
| 62 |
static_assert (__builtin_classify_type (__typeof__ (main)) == 10, ""); |
| 63 |
static_assert (__builtin_classify_type (__typeof__ (s)) == 12, ""); |
| 64 |
static_assert (__builtin_classify_type (__typeof__ (u)) == 13, ""); |
| 65 |
static_assert (__builtin_classify_type (__typeof__ (a)) == 14, ""); |
| 66 |
static_assert (__builtin_classify_type (__typeof__ (vi)) == 19, ""); |
| 67 |
static_assert (__builtin_classify_type (__typeof__ (vf)) == 19, ""); |
| 68 |
#ifndef __cplusplus |
| 69 |
static_assert (__builtin_classify_type (a[0]) == 1, ""); |
| 70 |
static_assert (__builtin_classify_type (e) == 1, ""); |
| 71 |
static_assert (__builtin_classify_type (b) == 1, ""); |
| 72 |
static_assert (__builtin_classify_type (p) == 5, ""); |
| 73 |
static_assert (__builtin_classify_type (f) == 8, ""); |
| 74 |
static_assert (__builtin_classify_type (c) == 9, ""); |
| 75 |
static_assert (__builtin_classify_type (main) == 5, ""); |
| 76 |
static_assert (__builtin_classify_type (s) == 12, ""); |
| 77 |
static_assert (__builtin_classify_type (u) == 13, ""); |
| 78 |
static_assert (__builtin_classify_type (a) == 5, ""); |
| 79 |
#endif |
| 80 |
if (__builtin_classify_type (a[0]) != 1) |
| 81 |
abort (); |
| 82 |
#ifdef __cplusplus |
| 83 |
if (__builtin_classify_type (e) != 3) |
| 84 |
abort (); |
| 85 |
if (__builtin_classify_type (b) != 4) |
| 86 |
abort (); |
| 87 |
#else |
| 88 |
if (__builtin_classify_type (e) != 1) |
| 89 |
abort (); |
| 90 |
if (__builtin_classify_type (b) != 1) |
| 91 |
abort (); |
| 92 |
#endif |
| 93 |
if (__builtin_classify_type (p) != 5) |
| 94 |
abort (); |
| 95 |
#ifdef __cplusplus |
| 96 |
if (__builtin_classify_type (r) != 1) |
| 97 |
abort (); |
| 98 |
if (__builtin_classify_type (q) != 7) |
| 99 |
abort (); |
| 100 |
#endif |
| 101 |
if (__builtin_classify_type (f) != 8) |
| 102 |
abort (); |
| 103 |
if (__builtin_classify_type (c) != 9) |
| 104 |
abort (); |
| 105 |
if (__builtin_classify_type (main) != 5) |
| 106 |
abort (); |
| 107 |
if (__builtin_classify_type (s) != 12) |
| 108 |
abort (); |
| 109 |
if (__builtin_classify_type (u) != 13) |
| 110 |
abort (); |
| 111 |
if (__builtin_classify_type (a) != 5) |
| 112 |
abort (); |
| 113 |
if (__builtin_classify_type (vi) != 19) |
| 114 |
abort (); |
| 115 |
if (__builtin_classify_type (vf) != 19) |
| 116 |
abort (); |
| 117 |
} |