Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / builtin-classify-type-1.c
bloba41dbe1630154fc840261d566f98ef52a33e5f3a
1 /* { dg-do run { target { c || c++11 } } } */
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
14 int
15 main ()
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 #ifdef __cplusplus
26 struct T { void foo (); };
27 int &r = a[0];
28 int S::*q = &S::s;
29 #endif
30 static_assert (__builtin_classify_type (void) == 0, "");
31 static_assert (__builtin_classify_type (int) == 1, "");
32 static_assert (__builtin_classify_type (enum E) == 3, "");
33 static_assert (__builtin_classify_type (bool) == 4, "");
34 static_assert (__builtin_classify_type (const char *) == 5, "");
35 #ifdef __cplusplus
36 static_assert (__builtin_classify_type (int &) == 6, "");
37 static_assert (__builtin_classify_type (int &&) == 6, "");
38 static_assert (__builtin_classify_type (int S::*) == 7, "");
39 #endif
40 static_assert (__builtin_classify_type (float) == 8, "");
41 static_assert (__builtin_classify_type (_Complex double) == 9, "");
42 static_assert (__builtin_classify_type (int (int, int)) == 10, "");
43 static_assert (__builtin_classify_type (struct S) == 12, "");
44 static_assert (__builtin_classify_type (union U) == 13, "");
45 static_assert (__builtin_classify_type (int [2]) == 14, "");
46 static_assert (__builtin_classify_type (__typeof__ (a[0])) == 1, "");
47 static_assert (__builtin_classify_type (__typeof__ (e)) == 3, "");
48 static_assert (__builtin_classify_type (__typeof__ (b)) == 4, "");
49 static_assert (__builtin_classify_type (__typeof__ (p)) == 5, "");
50 #ifdef __cplusplus
51 static_assert (__builtin_classify_type (decltype (r)) == 6, "");
52 static_assert (__builtin_classify_type (__typeof__ (q)) == 7, "");
53 #endif
54 static_assert (__builtin_classify_type (__typeof__ (f)) == 8, "");
55 static_assert (__builtin_classify_type (__typeof__ (c)) == 9, "");
56 static_assert (__builtin_classify_type (__typeof__ (main)) == 10, "");
57 static_assert (__builtin_classify_type (__typeof__ (s)) == 12, "");
58 static_assert (__builtin_classify_type (__typeof__ (u)) == 13, "");
59 static_assert (__builtin_classify_type (__typeof__ (a)) == 14, "");
60 #ifndef __cplusplus
61 static_assert (__builtin_classify_type (a[0]) == 1, "");
62 static_assert (__builtin_classify_type (e) == 1, "");
63 static_assert (__builtin_classify_type (b) == 1, "");
64 static_assert (__builtin_classify_type (p) == 5, "");
65 static_assert (__builtin_classify_type (f) == 8, "");
66 static_assert (__builtin_classify_type (c) == 9, "");
67 static_assert (__builtin_classify_type (main) == 5, "");
68 static_assert (__builtin_classify_type (s) == 12, "");
69 static_assert (__builtin_classify_type (u) == 13, "");
70 static_assert (__builtin_classify_type (a) == 5, "");
71 #endif
72 if (__builtin_classify_type (a[0]) != 1)
73 abort ();
74 #ifdef __cplusplus
75 if (__builtin_classify_type (e) != 3)
76 abort ();
77 if (__builtin_classify_type (b) != 4)
78 abort ();
79 #else
80 if (__builtin_classify_type (e) != 1)
81 abort ();
82 if (__builtin_classify_type (b) != 1)
83 abort ();
84 #endif
85 if (__builtin_classify_type (p) != 5)
86 abort ();
87 #ifdef __cplusplus
88 if (__builtin_classify_type (r) != 1)
89 abort ();
90 if (__builtin_classify_type (q) != 7)
91 abort ();
92 #endif
93 if (__builtin_classify_type (f) != 8)
94 abort ();
95 if (__builtin_classify_type (c) != 9)
96 abort ();
97 if (__builtin_classify_type (main) != 5)
98 abort ();
99 if (__builtin_classify_type (s) != 12)
100 abort ();
101 if (__builtin_classify_type (u) != 13)
102 abort ();
103 if (__builtin_classify_type (a) != 5)
104 abort ();