From a901c5f2040d4fb9452d1c80876bc11faab7af10 Mon Sep 17 00:00:00 2001 From: bellard Date: Sun, 27 Apr 2003 11:45:54 +0000 Subject: [PATCH] update --- tcctest.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tcctest.c b/tcctest.c index 85a1f663..885b1042 100644 --- a/tcctest.c +++ b/tcctest.c @@ -76,6 +76,7 @@ void typeof_test(void); void local_label_test(void); void statement_expr_test(void); void asm_test(void); +void builtin_test(void); int fib(int n); void num(int n); @@ -498,6 +499,7 @@ int main(int argc, char **argv) statement_expr_test(); local_label_test(); asm_test(); + builtin_test(); return 0; } @@ -1897,3 +1899,32 @@ void asm_test(void) } #endif + +#define COMPAT_TYPE(type1, type2) \ +{\ + printf("__builtin_types_compatible_p(%s, %s) = %d\n", #type1, #type2, \ + __builtin_types_compatible_p (type1, type2));\ +} + +int constant_p_var; + +void builtin_test(void) +{ +#if GCC_MAJOR >= 3 + COMPAT_TYPE(int, int); + COMPAT_TYPE(int, unsigned int); + COMPAT_TYPE(int, char); + COMPAT_TYPE(int, const int); + COMPAT_TYPE(int, volatile int); + COMPAT_TYPE(int *, int *); + COMPAT_TYPE(int *, void *); + COMPAT_TYPE(int *, const int *); + COMPAT_TYPE(char *, unsigned char *); +/* space is needed because tcc preprocessor introduces a space between each token */ + COMPAT_TYPE(char * *, void *); +#endif + printf("res = %d\n", __builtin_constant_p(1)); + printf("res = %d\n", __builtin_constant_p(1 + 2)); + printf("res = %d\n", __builtin_constant_p(&constant_p_var)); + printf("res = %d\n", __builtin_constant_p(constant_p_var)); +} -- 2.11.4.GIT