Mercurial > hg > qcc
changeset 256:b47b8f2aebf6
[project @ 2003-04-27 11:45:54 by bellard]
update
author | bellard |
---|---|
date | Sun, 27 Apr 2003 11:45:54 +0000 |
parents | e02822de9d86 |
children | 9aefaa6735e3 |
files | tcctest.c |
diffstat | 1 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tcctest.c Sun Apr 27 11:45:01 2003 +0000 +++ b/tcctest.c Sun Apr 27 11:45:54 2003 +0000 @@ -76,6 +76,7 @@ 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 @@ statement_expr_test(); local_label_test(); asm_test(); + builtin_test(); return 0; } @@ -1897,3 +1899,32 @@ } #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)); +}