forked from rui314/chibicc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuiltin.c
33 lines (28 loc) · 1.68 KB
/
builtin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "test.h"
int main() {
ASSERT(1, __builtin_types_compatible_p(int, int));
ASSERT(1, __builtin_types_compatible_p(double, double));
ASSERT(0, __builtin_types_compatible_p(int, long));
ASSERT(0, __builtin_types_compatible_p(long, float));
ASSERT(1, __builtin_types_compatible_p(int *, int *));
ASSERT(0, __builtin_types_compatible_p(short *, int *));
ASSERT(0, __builtin_types_compatible_p(int **, int *));
ASSERT(1, __builtin_types_compatible_p(const int, int));
ASSERT(0, __builtin_types_compatible_p(unsigned, int));
ASSERT(1, __builtin_types_compatible_p(signed, int));
ASSERT(0, __builtin_types_compatible_p(struct {int a;}, struct {int a;}));
ASSERT(1, __builtin_types_compatible_p(int (*)(void), int (*)(void)));
ASSERT(1, __builtin_types_compatible_p(void (*)(int), void (*)(int)));
ASSERT(1, __builtin_types_compatible_p(void (*)(int, double), void (*)(int, double)));
ASSERT(1, __builtin_types_compatible_p(int (*)(float, double), int (*)(float, double)));
ASSERT(0, __builtin_types_compatible_p(int (*)(float, double), int));
ASSERT(0, __builtin_types_compatible_p(int (*)(float, double), int (*)(float)));
ASSERT(0, __builtin_types_compatible_p(int (*)(float, double), int (*)(float, double, int)));
ASSERT(1, __builtin_types_compatible_p(double (*)(...), double (*)(...)));
ASSERT(0, __builtin_types_compatible_p(double (*)(...), double (*)(void)));
ASSERT(1, ({ typedef struct {int a;} T; __builtin_types_compatible_p(T, T); }));
ASSERT(1, ({ typedef struct {int a;} T; __builtin_types_compatible_p(T, const T); }));
ASSERT(1, ({ struct {int a; int b;} x; __builtin_types_compatible_p(typeof(x.a), typeof(x.b)); }));
printf("OK\n");
return 0;
}