Unified · Split
| @@ -76,6 +76,7 @@ void typeof_test(void); · 75 unmodified lines | |||
| 76 | void local_label_test(void); | 76 | void local_label_test(void); |
| 77 | void statement_expr_test(void); | 77 | void statement_expr_test(void); |
| 78 | void asm_test(void); | 78 | void asm_test(void); |
| 79 | void builtin_test(void); | ||
| 79 | 80 | ||
| 80 | int fib(int n); | 81 | int fib(int n); |
| 81 | void num(int n); | 82 | void num(int n); |
| @@ -498,6 +499,7 @@ int main(int argc, char **argv) · 416 unmodified lines | |||
| 498 | statement_expr_test(); | 499 | statement_expr_test(); |
| 499 | local_label_test(); | 500 | local_label_test(); |
| 500 | asm_test(); | 501 | asm_test(); |
| 502 | builtin_test(); | ||
| 501 | return 0; | 503 | return 0; |
| 502 | } | 504 | } |
| 503 | 505 | ||
| @@ -1897,3 +1899,32 @@ void asm_test(void) · 1393 unmodified lines | |||
| 1897 | } | 1899 | } |
| 1898 | 1900 | ||
| 1899 | #endif | 1901 | #endif |
| 1902 | |||
| 1903 | #define COMPAT_TYPE(type1, type2) \ | ||
| 1904 | {\ | ||
| 1905 | printf("__builtin_types_compatible_p(%s, %s) = %d\n", #type1, #type2, \ | ||
| 1906 | __builtin_types_compatible_p (type1, type2));\ | ||
| 1907 | } | ||
| 1908 | |||
| 1909 | int constant_p_var; | ||
| 1910 | |||
| 1911 | void builtin_test(void) | ||
| 1912 | { | ||
| 1913 | #if GCC_MAJOR >= 3 | ||
| 1914 | COMPAT_TYPE(int, int); | ||
| 1915 | COMPAT_TYPE(int, unsigned int); | ||
| 1916 | COMPAT_TYPE(int, char); | ||
| 1917 | COMPAT_TYPE(int, const int); | ||
| 1918 | COMPAT_TYPE(int, volatile int); | ||
| 1919 | COMPAT_TYPE(int *, int *); | ||
| 1920 | COMPAT_TYPE(int *, void *); | ||
| 1921 | COMPAT_TYPE(int *, const int *); | ||
| 1922 | COMPAT_TYPE(char *, unsigned char *); | ||
| 1923 | /* space is needed because tcc preprocessor introduces a space between each token */ | ||
| 1924 | COMPAT_TYPE(char * *, void *); | ||
| 1925 | #endif | ||
| 1926 | printf("res = %d\n", __builtin_constant_p(1)); | ||
| 1927 | printf("res = %d\n", __builtin_constant_p(1 + 2)); | ||
| 1928 | printf("res = %d\n", __builtin_constant_p(&constant_p_var)); | ||
| 1929 | printf("res = %d\n", __builtin_constant_p(constant_p_var)); | ||
| 1930 | } | ||