1 /* { dg-do run { target { c || c++11 } } } */
3 #if !defined(__cplusplus) && __STDC_VERSION__ <= 201710L
4 #define static_assert _Static_assert
6 #define false ((_Bool) 0)
9 extern "C" void abort ();
11 extern void abort (void);
18 struct S
{ int s
; } s
= { 0 };
19 union U
{ int u
; } u
= { 0 };
22 const char *p
= (const char *) 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
};
30 struct T
{ void foo (); };
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, "");
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, "");
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, "");
57 static_assert (__builtin_classify_type (decltype (r
)) == 6, "");
58 static_assert (__builtin_classify_type (__typeof__ (q
)) == 7, "");
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, "");
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, "");
80 if (__builtin_classify_type (a
[0]) != 1)
83 if (__builtin_classify_type (e
) != 3)
85 if (__builtin_classify_type (b
) != 4)
88 if (__builtin_classify_type (e
) != 1)
90 if (__builtin_classify_type (b
) != 1)
93 if (__builtin_classify_type (p
) != 5)
96 if (__builtin_classify_type (r
) != 1)
98 if (__builtin_classify_type (q
) != 7)
101 if (__builtin_classify_type (f
) != 8)
103 if (__builtin_classify_type (c
) != 9)
105 if (__builtin_classify_type (main
) != 5)
107 if (__builtin_classify_type (s
) != 12)
109 if (__builtin_classify_type (u
) != 13)
111 if (__builtin_classify_type (a
) != 5)
113 if (__builtin_classify_type (vi
) != 19)
115 if (__builtin_classify_type (vf
) != 19)