History

update

bellard committed 23 years ago

Commit a901c5f1 parent 2b64f2f1 file · +31 −0Browse files

Unified · Split

tcctest.c+31−0
@@ -76,6 +76,7 @@ void typeof_test(void); · 75 unmodified lines
7676 void local_label_test(void);
7777 void statement_expr_test(void);
7878 void asm_test(void);
79+void builtin_test(void);
7980
8081 int fib(int n);
8182 void num(int n);
@@ -498,6 +499,7 @@ int main(int argc, char **argv) · 416 unmodified lines
498499 statement_expr_test();
499500 local_label_test();
500501 asm_test();
502+ builtin_test();
501503 return 0;
502504 }
503505
@@ -1897,3 +1899,32 @@ void asm_test(void) · 1393 unmodified lines
18971899 }
18981900
18991901 #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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t