Unified · Split
| @@ -1,17 +1,23 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | * TCC auto test program |
| 3 | 3 | */ |
| 4 | +#include "config.h" | |
| 5 | + | |
| 6 | +#if GCC_MAJOR >= 3 | |
| 4 | 7 | |
| 5 | 8 | /* Unfortunately, gcc version < 3 does not handle that! */ |
| 6 | −//#define ALL_ISOC99 | |
| 9 | +#define ALL_ISOC99 | |
| 7 | 10 | |
| 8 | 11 | /* only gcc 3 handles _Bool correctly */ |
| 9 | −//#define BOOL_ISOC99 | |
| 10 | − | |
| 11 | −#define C99_MACROS | |
| 12 | +#define BOOL_ISOC99 | |
| 12 | 13 | |
| 13 | 14 | /* gcc 2.95.3 does not handle correctly CR in strings or after strays */ |
| 14 | −//#define CORRECT_CR_HANDLING | |
| 15 | +#define CORRECT_CR_HANDLING | |
| 16 | + | |
| 17 | +#endif | |
| 18 | + | |
| 19 | +/* __VA_ARGS__ and __func__ support */ | |
| 20 | +#define C99_MACROS | |
| 15 | 21 | |
| 16 | 22 | /* test various include syntaxes */ |
| 17 | 23 | |
| @@ -228,8 +234,21 @@ void macro_test(void) · 210 unmodified lines | ||
| 228 | 234 | printf("a=%d\n", a); |
| 229 | 235 | } |
| 230 | 236 | |
| 237 | + /* macro function with argument outside the macro string */ | |
| 238 | +#define MF_s MF_hello | |
| 239 | +#define MF_hello(msg) printf("%s\n",msg) | |
| 240 | + | |
| 241 | +#define MF_t printf("tralala\n"); MF_hello | |
| 242 | + | |
| 243 | + MF_s("hi"); | |
| 244 | + MF_t("hi"); | |
| 245 | + | |
| 231 | 246 | /* comment with stray handling *\ |
| 232 | 247 | / |
| 248 | + /* this is a valid *\/ comment */ | |
| 249 | + /* this is a valid comment *\*/ | |
| 250 | + // this is a valid\ | |
| 251 | +comment | |
| 233 | 252 | } |
| 234 | 253 | |
| 235 | 254 | int op(a,b) |
| @@ -258,6 +277,11 @@ void ps(char *s) · 22 unmodified lines | ||
| 258 | 277 | } |
| 259 | 278 | } |
| 260 | 279 | |
| 280 | +const char foo1_string[] = "\ | |
| 281 | +bar\n\ | |
| 282 | +test\14\ | |
| 283 | +1"; | |
| 284 | + | |
| 261 | 285 | void string_test() |
| 262 | 286 | { |
| 263 | 287 | int b; |
| @@ -266,6 +290,7 @@ void string_test() · 2 unmodified lines | ||
| 266 | 290 | printf("\x41\x42\x43\x3a\n"); |
| 267 | 291 | printf("c=%c\n", 'r'); |
| 268 | 292 | printf("wc=%C 0x%lx %C\n", L'a', L'\x1234', L'c'); |
| 293 | + printf("foo1_string='%s'\n", foo1_string); | |
| 269 | 294 | #if 0 |
| 270 | 295 | printf("wstring=%S\n", L"abc"); |
| 271 | 296 | printf("wstring=%S\n", L"abc" L"def" "ghi"); |
| @@ -1647,9 +1672,22 @@ void old_style_f(a,b,c) · 1375 unmodified lines | ||
| 1647 | 1672 | printf("a=%d b=%d b=%f\n", a, b, c); |
| 1648 | 1673 | } |
| 1649 | 1674 | |
| 1675 | +void decl_func1(int cmpfn()) | |
| 1676 | +{ | |
| 1677 | + printf("cmpfn=%lx\n", (long)cmpfn); | |
| 1678 | +} | |
| 1679 | + | |
| 1680 | +void decl_func2(cmpfn) | |
| 1681 | +int cmpfn(); | |
| 1682 | +{ | |
| 1683 | + printf("cmpfn=%lx\n", (long)cmpfn); | |
| 1684 | +} | |
| 1685 | + | |
| 1650 | 1686 | void old_style_function(void) |
| 1651 | 1687 | { |
| 1652 | 1688 | old_style_f((void *)1, 2, 3.0); |
| 1689 | + decl_func1(NULL); | |
| 1690 | + decl_func2(NULL); | |
| 1653 | 1691 | } |
| 1654 | 1692 | |
| 1655 | 1693 | void sizeof_test(void) |