2 * TCC auto test program
8 /* Unfortunately, gcc version < 3 does not handle that! */
11 /* only gcc 3 handles _Bool correctly */
14 /* gcc 2.95.3 does not handle correctly CR in strings or after strays */
15 #define CORRECT_CR_HANDLING
19 /* deprecated and no longer supported in gcc 3.3 */
20 //#define ACCEPT_CR_IN_STRINGS
22 /* __VA_ARGS__ and __func__ support */
25 /* test various include syntaxes */
27 #define TCCLIB_INC <tcclib.h>
28 #define TCCLIB_INC1 <tcclib
29 #define TCCLIB_INC2 h>
30 #define TCCLIB_INC3 "tcclib"
34 #include TCCLIB_INC1.TCCLIB_INC2
36 #include TCCLIB_INC1.h>
38 /* gcc 3.2 does not accept that (bug ?) */
39 //#include TCCLIB_INC3 ".h"
48 void recursive_macro_test();
62 void constant_expr_test();
64 void char_short_test();
66 void compound_literal_test(void);
68 void struct_assign_test(void);
70 void bitfield_test(void);
71 void c99_bool_test(void);
72 void float_test(void);
73 void longlong_test(void);
74 void manyarg_test(void);
75 void stdarg_test(void);
76 void whitespace_test(void);
77 void relocation_test(void);
78 void old_style_function(void);
79 void alloca_test(void);
80 void sizeof_test(void);
81 void typeof_test(void);
82 void local_label_test(void);
83 void statement_expr_test(void);
85 void builtin_test(void);
90 void forward_ref(void);
96 #define M1(a, b) (a) + (b)
100 #define glue(a, b) a ## b
101 #define xglue(a, b) glue(a, b)
102 #define HIGHLOW "hello"
103 #define LOW LOW ", world"
105 #define min(a, b) ((a) < (b) ? (a) : (b))
108 #define dprintf(level,...) printf(__VA_ARGS__)
111 /* gcc vararg macros */
112 #define dprintf1(level, fmt, args...) printf(fmt, ## args)
114 #define MACRO_NOARGS()
130 #define __INT64_C(c) c ## LL
131 #define INT64_MIN (-__INT64_C(9223372036854775807)-1)
139 #define spin_lock(lock) do { } while (0)
140 #define wq_spin_lock spin_lock
141 #define TEST2() wq_spin_lock(a)
143 void macro_test(void)
145 printf("macro:\n");\f\v
147 printf("aaa=%d\n", AAA
);
149 printf("min=%d\n", min(1, min(2, -1)));
151 printf("s1=%s\n", glue(HIGH
, LOW
));
152 printf("s2=%s\n", xglue(HIGH
, LOW
));
153 printf("s3=%s\n", str("c"));
154 printf("s4=%s\n", str(a1
));
155 printf("B3=%d\n", B3
);
158 printf("A defined\n");
161 printf("B defined\n");
164 printf("A defined\n");
166 printf("A not defined\n");
169 printf("B defined\n");
171 printf("B not defined\n");
175 printf("A defined\n");
177 printf("B1 defined\n");
179 printf("B1 not defined\n");
182 printf("A not defined\n");
184 printf("B2 defined\n");
186 printf("B2 not defined\n");
191 printf("test true1\n");
194 printf("test true2\n");
197 printf("test true3\n");
200 printf("test trueA\n");
203 printf("test trueB\n");
219 printf("__LINE__ defined\n");
222 printf("__LINE__=%d __FILE__=%s\n",
225 printf("__LINE__=%d __FILE__=%s\n",
228 printf("__LINE__=%d __FILE__=%s\n",
230 #line 227 "tcctest.c"
232 /* not strictly preprocessor, but we test it there */
234 printf("__func__ = %s\n", __func__
);
235 dprintf(1, "vaarg=%d\n", 1);
237 dprintf1(1, "vaarg1\n");
238 dprintf1(1, "vaarg1=%d\n", 2);
239 dprintf1(1, "vaarg1=%d %d\n", 1, 2);
242 printf("func='%s'\n", __FUNCTION__
);
244 /* complicated macros in glibc */
245 printf("INT64_MIN=%Ld\n", INT64_MIN
);
255 /* macro function with argument outside the macro string */
256 #define MF_s MF_hello
257 #define MF_hello(msg) printf("%s\n",msg)
259 #define MF_t printf("tralala\n"); MF_hello
264 /* test macro substituion inside args (should not eat stream) */
265 printf("qq=%d\n", qq(qq
)(2));
267 /* test zero argument case. NOTE: gcc 2.95.x does not accept a
268 null argument without a space. gcc 3.2 fixes that. */
271 printf("qq1=%d\n", qq1( ));
273 /* comment with stray handling *\
275 /* this is a valid *\/ comment */
276 /* this is a valid comment *\*/
280 /* test function macro substitution when the function name is
286 static void print_num(char *fn
, int line
, int num
) {
287 printf("fn %s, line %d, num %d\n", fn
, line
, num
);
290 void recursive_macro_test(void)
292 #if 0 /* doesnt work yet */
293 #define ELF32_ST_TYPE(val) ((val) & 0xf)
294 #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
295 #define STB_WEAK 2 /* Weak symbol */
296 #define ELFW(type) ELF##32##_##type
297 printf("%d\n", ELFW(ST_INFO
)(STB_WEAK
, ELFW(ST_TYPE
)(123)));
302 #define print_num(x) print_num(__FILE__,__LINE__,x)
304 WRAP(print_num(123));
305 WRAP(WRAP(print_num(123)));
307 static struct recursive_macro
{ int rm_field
; } G
;
308 #define rm_field (G.rm_field)
309 printf("rm_field = %d\n", rm_field
);
310 printf("rm_field = %d\n", WRAP(rm_field
));
311 WRAP((printf("rm_field = %d %d\n", rm_field
, WRAP(rm_field
))));
328 void ps(const char *s
)
340 const char foo1_string
[] = "\
349 printf("\141\1423\143\n");/* dezdez test */
350 printf("\x41\x42\x43\x3a\n");
351 printf("c=%c\n", 'r');
352 printf("wc=%C 0x%lx %C\n", L
'a', L
'\x1234', L
'c');
353 printf("foo1_string='%s'\n", foo1_string
);
355 printf("wstring=%S\n", L
"abc");
356 printf("wstring=%S\n", L
"abc" L
"def" "ghi");
357 printf("'\\377'=%d '\\xff'=%d\n", '\377', '\xff');
358 printf("L'\\377'=%d L'\\xff'=%d\n", L
'\377', L
'\xff');
362 while ((b
= b
+ 1) < 96) {
366 printf("fib=%d\n", fib(33));
368 while (b
!= 0x80000000) {
381 for(i
= 0; i
< 10;i
++)
390 /* break/continue tests */
402 /* break/continue tests */
414 for(i
= 0;i
< 10;i
++) {
426 static void *label_table
[3] = { &&label1
, &&label2
, &&label3
};
439 /* we also test computed gotos (GCC extension) */
441 goto *label_table
[i
];
469 printf("enum:\n%d %d %d %d %d %d\n",
470 E0
, E1
, E2
, E3
, E4
, E5
);
472 printf("b1=%d\n", b1
);
488 printf("typedef:\n");
489 printf("a=%d\n", *a
);
491 printf("mytype2=%d\n", mytype2
);
496 printf("forward:\n");
502 void forward_ref(void)
504 printf("forward ok\n");
507 typedef struct struct1
{
527 struct struct1 st1
, st2
;
529 int main(int argc
, char **argv
)
534 recursive_macro_test();
548 constant_expr_test();
552 compound_literal_test();
554 struct_assign_test();
564 old_style_function();
568 statement_expr_test();
583 printf("g1=%d\n", g
);
591 printf("g2=%d\n", g
);
595 printf("g3=%d\n", g
);
599 printf("g4=%d\n", g
);
602 printf("g5=%d\n", g
);
605 void array_test(int a
[4])
610 printf("sizeof(a) = %d\n", sizeof(a
));
611 printf("sizeof(\"a\") = %d\n", sizeof("a"));
613 printf("sizeof(__func__) = %d\n", sizeof(__func__
));
615 printf("sizeof tab %d\n", sizeof(tab
));
616 printf("sizeof tab2 %d\n", sizeof tab2
);
620 printf("%d %d %d\n", tab
[0], tab
[1], tab
[2]);
623 tab2
[i
][j
] = 10 * i
+ j
;
625 printf(" %3d", ((int *)tab2
)[i
]);
628 printf("sizeof(size_t)=%d\n", sizeof(size_t));
629 printf("sizeof(ptrdiff_t)=%d\n", sizeof(ptrdiff_t));
636 printf("%d\n", a
+= 1);
637 printf("%d\n", a
-= 2);
638 printf("%d\n", a
*= 31232132);
639 printf("%d\n", a
/= 4);
640 printf("%d\n", a
%= 20);
641 printf("%d\n", a
&= 6);
642 printf("%d\n", a
^= 7);
643 printf("%d\n", a
|= 8);
644 printf("%d\n", a
>>= 3);
645 printf("%d\n", a
<<= 4);
649 printf("%d\n", a
+ 1);
650 printf("%d\n", a
- 2);
651 printf("%d\n", a
* 312);
652 printf("%d\n", a
/ 4);
653 printf("%d\n", b
/ 4);
654 printf("%d\n", (unsigned)b
/ 4);
655 printf("%d\n", a
% 20);
656 printf("%d\n", b
% 20);
657 printf("%d\n", (unsigned)b
% 20);
658 printf("%d\n", a
& 6);
659 printf("%d\n", a
^ 7);
660 printf("%d\n", a
| 8);
661 printf("%d\n", a
>> 3);
662 printf("%d\n", b
>> 3);
663 printf("%d\n", (unsigned)b
>> 3);
664 printf("%d\n", a
<< 4);
669 printf("%d\n", 12 + 1);
670 printf("%d\n", 12 - 2);
671 printf("%d\n", 12 * 312);
672 printf("%d\n", 12 / 4);
673 printf("%d\n", 12 % 20);
674 printf("%d\n", 12 & 6);
675 printf("%d\n", 12 ^ 7);
676 printf("%d\n", 12 | 8);
677 printf("%d\n", 12 >> 2);
678 printf("%d\n", 12 << 4);
682 printf("%d %d %d %d\n",
691 return (c
>= 'a' & c
<= 'z') | (c
>= 'A' & c
<= 'Z') | c
== '_';
694 /**********************/
696 int vstack
[10], *vstack_ptr
;
698 void vpush(int vt
, int vc
)
704 void vpop(int *ft
, int *fc
)
717 vstack_ptr
[-2] &= ~0xffffff80;
719 printf("res= %d %d\n", a
, b
);
722 void constant_expr_test()
725 printf("constant_expr:\n");
727 printf("%d\n", a
* 16);
728 printf("%d\n", a
* 1);
729 printf("%d\n", a
+ 0);
739 printf("expr_ptr:\n");
742 printf("diff=%d\n", q
- p
);
744 printf("inc=%d\n", p
- tab4
);
746 printf("dec=%d\n", p
- tab4
);
748 printf("inc=%d\n", p
- tab4
);
750 printf("dec=%d\n", p
- tab4
);
751 printf("add=%d\n", p
+ 3 - tab4
);
752 printf("add=%d\n", 3 + p
- tab4
);
754 /* check if 64bit support is ok */
757 printf("%p %p %ld\n", q
, p
, p
-q
);
758 printf("%d %d %d %d %d %d\n",
759 p
== q
, p
!= q
, p
< q
, p
<= q
, p
>= q
, p
> q
);
762 printf("%p %p %ld\n", q
, p
, p
-q
);
763 printf("%d %d %d %d %d %d\n",
764 p
== q
, p
!= q
, p
< q
, p
<= q
, p
>= q
, p
> q
);
765 p
= (int *)((char *)p
+ 0xf0000000);
766 printf("%p %p %ld\n", q
, p
, p
-q
);
767 printf("%d %d %d %d %d %d\n",
768 p
== q
, p
!= q
, p
< q
, p
<= q
, p
>= q
, p
> q
);
770 printf("%p %p %ld\n", q
, p
, p
-q
);
771 printf("%d %d %d %d %d %d\n",
772 p
== q
, p
!= q
, p
< q
, p
<= q
, p
>= q
, p
> q
);
777 struct size12 s
[2], *sp
= s
;
782 printf("%d\n", sp
[j
].i
);
789 printf("constant_expr:\n");
792 printf("%d\n", a
== a
);
793 printf("%d\n", a
!= a
);
795 printf("%d\n", a
< b
);
796 printf("%d\n", a
<= b
);
797 printf("%d\n", a
<= a
);
798 printf("%d\n", b
>= a
);
799 printf("%d\n", a
>= a
);
800 printf("%d\n", b
> a
);
802 printf("%d\n", (unsigned)a
< b
);
803 printf("%d\n", (unsigned)a
<= b
);
804 printf("%d\n", (unsigned)a
<= a
);
805 printf("%d\n", (unsigned)b
>= a
);
806 printf("%d\n", (unsigned)a
>= a
);
807 printf("%d\n", (unsigned)b
> a
);
836 printf("sizes: %d %d %d %d\n",
837 sizeof(struct struct1
),
838 sizeof(struct struct2
),
839 sizeof(union union1
),
840 sizeof(union union2
));
844 printf("st1: %d %d %d\n",
845 st1
.f1
, st1
.f2
, st1
.f3
);
848 printf("union1: %d\n", st1
.u
.v1
);
851 printf("union2: %d\n", u
.w1
);
856 printf("st2: %d %d %d\n",
857 s
->f1
, s
->f2
, s
->f3
);
858 printf("str_addr=%x\n", (int)st1
.str
- (int)&st1
.f1
);
860 /* align / size tests */
861 printf("aligntest1 sizeof=%d alignof=%d\n",
862 sizeof(struct aligntest1
), __alignof__(struct aligntest1
));
863 printf("aligntest2 sizeof=%d alignof=%d\n",
864 sizeof(struct aligntest2
), __alignof__(struct aligntest2
));
865 printf("aligntest3 sizeof=%d alignof=%d\n",
866 sizeof(struct aligntest3
), __alignof__(struct aligntest3
));
867 printf("aligntest4 sizeof=%d alignof=%d\n",
868 sizeof(struct aligntest4
), __alignof__(struct aligntest4
));
870 /* empty structures (GCC extension) */
871 printf("sizeof(struct empty) = %d\n", sizeof(struct empty
));
872 printf("alignof(struct empty) = %d\n", __alignof__(struct empty
));
875 /* XXX: depend on endianness */
876 void char_short_test()
880 printf("char_short:\n");
885 *(char *)&var1
, *(char *)&var2
);
887 *(unsigned char *)&var1
, *(unsigned char *)&var2
);
888 printf("s16=%d %d\n",
889 *(short *)&var1
, *(short *)&var2
);
890 printf("u16=%d %d\n",
891 *(unsigned short *)&var1
, *(unsigned short *)&var2
);
892 printf("s32=%d %d\n",
893 *(int *)&var1
, *(int *)&var2
);
894 printf("u32=%d %d\n",
895 *(unsigned int *)&var1
, *(unsigned int *)&var2
);
896 *(char *)&var1
= 0x08;
897 printf("var1=%x\n", var1
);
898 *(short *)&var1
= 0x0809;
899 printf("var1=%x\n", var1
);
900 *(int *)&var1
= 0x08090a0b;
901 printf("var1=%x\n", var1
);
914 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
915 #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
917 static int toupper1(int a
)
924 int *s
, a
, b
, t
, f
, i
;
928 printf("!s=%d\n", !s
);
934 printf("a=%d %d %d\n", 0 || 0, 0 || 1, 1 || 1);
935 printf("a=%d %d %d\n", 0 && 0, 0 && 1, 1 && 1);
936 printf("a=%d %d\n", 1 ? 1 : 0, 0 ? 1 : 0);
951 printf("b=%d\n", a
+ (0 ? 1 : a
/ 2));
953 /* test register spilling */
956 a
= (a
+ b
) * ((a
< b
) ?
957 ((b
- a
) * (a
- b
)): a
+ b
);
960 /* test complex || or && expressions */
964 printf("exp=%d\n", f
== (32 <= a
&& a
<= 3));
965 printf("r=%d\n", (t
|| f
) + (t
&& f
));
970 int aspect_native
= 65536;
971 double bfu_aspect
= 1.0;
973 for(aspect_on
= 0; aspect_on
< 2; aspect_on
++) {
974 aspect
=aspect_on
?(aspect_native
*bfu_aspect
+0.5):65535UL;
975 printf("aspect=%d\n", aspect
);
979 /* test ? : GCC extension */
981 static int v1
= 34 ? : -1; /* constant case */
982 static int v2
= 0 ? : -1; /* constant case */
985 printf("%d %d\n", v1
, v2
);
986 printf("%d %d\n", a
- 30 ? : a
* 2, a
+ 1 ? : a
* 2);
989 /* again complex expression */
991 if (toupper1 (i
) != TOUPPER (i
))
992 printf("error %d\n", i
);
996 /* GCC accepts that */
997 static int tab_reinit
[];
998 static int tab_reinit
[10];
1000 //int cinit1; /* a global variable can be defined several times without error ! */
1004 int *cinit2
= (int []){3, 2, 1};
1006 void compound_literal_test(void)
1011 printf("compound_test:\n");
1013 p
= (int []){1, 2, 3};
1015 printf(" %d", p
[i
]);
1019 printf("%d", cinit2
[i
]);
1023 printf("q1=%s\n", q
);
1025 q
= (char *){ "tralala2" };
1026 printf("q2=%s\n", q
);
1029 printf("q3=%s\n", q3
);
1031 q
= (char []){ "tralala3" };
1032 printf("q4=%s\n", q
);
1035 p
= (int []){1, 2, cinit1
+ 3};
1037 printf(" %d", p
[i
]);
1041 p
= (int []){1, 2, 4 + i
};
1042 printf("%d %d %d\n",
1064 printf("kr_test:\n");
1065 printf("func1=%d\n", kr_func1(3, 4));
1066 printf("func2=%d\n", kr_func2(3, 4));
1073 tab
= (char*)malloc(20);
1090 /* structure assignment tests */
1096 struct structa1 ssta1
;
1098 void struct_assign_test1(struct structa1 s1
, int t
, float f
)
1100 printf("%d %d %d %f\n", s1
.f1
, s1
.f2
, t
, f
);
1103 struct structa1
struct_assign_test2(struct structa1 s1
, int t
)
1110 void struct_assign_test(void)
1112 struct structa1 lsta1
, lsta2
;
1115 printf("struct_assign_test:\n");
1119 printf("%d %d\n", lsta1
.f1
, lsta1
.f2
);
1121 printf("%d %d\n", lsta2
.f1
, lsta2
.f2
);
1126 struct_assign_test1(lsta2
, 3, 4.5);
1128 printf("before call: %d %d\n", lsta2
.f1
, lsta2
.f2
);
1129 lsta2
= struct_assign_test2(lsta2
, 4);
1130 printf("after call: %d %d\n", lsta2
.f1
, lsta2
.f2
);
1135 /* XXX: we should allow this even without braces */
1136 { struct_assign_test
}
1138 printf("%d\n", struct_assign_test
== t
[0].elem
);
1141 /* casts to short/char */
1143 void cast1(char a
, short b
, unsigned char c
, unsigned short d
)
1145 printf("%d %d %d %d\n", a
, b
, c
, d
);
1159 p
-= 0x700000000042;
1161 printf("cast_test:\n");
1165 printf("%d %d %d %d\n",
1168 (unsigned char)(a
+ 1),
1169 (unsigned short)(a
+ 1));
1170 printf("%d %d %d %d\n",
1173 (unsigned char)0xfffff,
1174 (unsigned short)0xfffff);
1176 a
= (bcast
= 128) + 1;
1178 a
= (scast
= 65536) + 1;
1181 printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c
), sizeof((int)c
));
1183 /* test cast from unsigned to signed short to int */
1186 printf("((unsigned)(short)0x%08x) = 0x%08x\n", b
, d
);
1189 printf("((unsigned)(char)0x%08x) = 0x%08x\n", b
, d
);
1191 /* test implicit int casting for array accesses */
1195 printf("%d %d\n", tab
[0], tab
[1]);
1197 /* test implicit casting on some operators */
1198 printf("sizeof(+(char)'a') = %d\n", sizeof(+(char)'a'));
1199 printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
1200 printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
1202 /* from pointer to integer types */
1203 printf("%d %d %ld %ld %lld %lld\n",
1204 (int)p
, (unsigned int)p
,
1205 (long)p
, (unsigned long)p
,
1206 (long long)p
, (unsigned long long)p
);
1208 /* from integers to pointers */
1209 printf("%p %p %p %p\n",
1210 (void *)a
, (void *)b
, (void *)c
, (void *)d
);
1213 /* initializers tests */
1214 struct structinit1
{
1223 int sinit3
[3] = { 1, 2, {{3}}, };
1224 int sinit4
[3][2] = { {1, 2}, {3, 4}, {5, 6} };
1225 int sinit5
[3][2] = { 1, 2, 3, 4, 5, 6 };
1226 int sinit6
[] = { 1, 2, 3 };
1227 int sinit7
[] = { [2] = 3, [0] = 1, 2 };
1228 char sinit8
[] = "hello" "trala";
1230 struct structinit1 sinit9
= { 1, 2, 3 };
1231 struct structinit1 sinit10
= { .f2
= 2, 3, .f1
= 1 };
1232 struct structinit1 sinit11
= { .f2
= 2, 3, .f1
= 1,
1240 char *sinit12
= "hello world";
1246 char sinit14
[10] = { "abc" };
1247 int sinit15
[3] = { sizeof(sinit15
), 1, 2 };
1249 struct { int a
[3], b
; } sinit16
[] = { { 1 }, 2 };
1265 struct complexinit0
{
1270 struct complexinit
{
1272 const struct complexinit0
*b
;
1275 const static struct complexinit cix
[] = {
1278 .b
= (const struct complexinit0
[]) {
1286 struct complexinit2
{
1291 struct complexinit2 cix21
= {
1293 .b
= { 3001, 3002, 3003 }
1296 struct complexinit2 cix22
= {
1298 .b
= { 4001, 4002, 4003, 4004, 4005, 4006 }
1301 void init_test(void)
1305 int linit4
[3][2] = { {1, 2}, {3, 4}, {5, 6} };
1306 int linit6
[] = { 1, 2, 3 };
1308 char linit8
[] = "hello" "trala";
1309 int linit12
[10] = { 1, 2 };
1310 int linit13
[10] = { 1, 2, [7] = 3, [3] = 4, };
1311 char linit14
[10] = "abc";
1312 int linit15
[10] = { linit1
, linit1
+ 1, [6] = linit1
+ 2, };
1313 struct linit16
{ int a1
, a2
, a3
, a4
; } linit16
= { 1, .a3
= 2 };
1314 int linit17
= sizeof(linit17
);
1316 printf("init_test:\n");
1318 printf("sinit1=%d\n", sinit1
);
1319 printf("sinit2=%d\n", sinit2
);
1320 printf("sinit3=%d %d %d %d\n",
1326 printf("sinit6=%d\n", sizeof(sinit6
));
1327 printf("sinit7=%d %d %d %d\n",
1333 printf("sinit8=%s\n", sinit8
);
1334 printf("sinit9=%d %d %d\n",
1339 printf("sinit10=%d %d %d\n",
1344 printf("sinit11=%d %d %d %d %d %d\n",
1355 printf("[%d][%d] = %d %d %d\n",
1356 i
, j
, sinit4
[i
][j
], sinit5
[i
][j
], linit4
[i
][j
]);
1357 printf("linit1=%d\n", linit1
);
1358 printf("linit2=%d\n", linit2
);
1359 printf("linit6=%d\n", sizeof(linit6
));
1360 printf("linit8=%d %s\n", sizeof(linit8
), linit8
);
1362 printf("sinit12=%s\n", sinit12
);
1363 printf("sinit13=%d %s %s %s\n",
1368 printf("sinit14=%s\n", sinit14
);
1370 for(i
=0;i
<10;i
++) printf(" %d", linit12
[i
]);
1372 for(i
=0;i
<10;i
++) printf(" %d", linit13
[i
]);
1374 for(i
=0;i
<10;i
++) printf(" %d", linit14
[i
]);
1376 for(i
=0;i
<10;i
++) printf(" %d", linit15
[i
]);
1378 printf("%d %d %d %d\n",
1383 /* test that initialisation is done after variable declare */
1384 printf("linit17=%d\n", linit17
);
1385 printf("sinit15=%d\n", sinit15
[0]);
1386 printf("sinit16=%d %d\n", sinit16
[0].a
[0], sinit16
[1].a
[0]);
1387 printf("sinit17=%s %d %s %d\n",
1388 sinit17
[0].s
, sinit17
[0].len
,
1389 sinit17
[1].s
, sinit17
[1].len
);
1391 printf("%x ", sinit18
[i
]);
1393 /* complex init check */
1394 printf("cix: %d %d %d %d %d %d %d\n",
1396 cix
[0].b
[0].a
, cix
[0].b
[0].b
,
1397 cix
[0].b
[1].a
, cix
[0].b
[1].b
,
1398 cix
[0].b
[2].a
, cix
[0].b
[2].b
);
1399 printf("cix2: %d %d\n", cix21
.b
[2], cix22
.b
[5]);
1427 /* ISOC99 _Bool type */
1428 void c99_bool_test(void)
1434 printf("bool_test:\n");
1435 printf("sizeof(_Bool) = %d\n", sizeof(_Bool
));
1437 printf("cast: %d %d %d\n", (_Bool
)10, (_Bool
)0, (_Bool
)a
);
1439 printf("b = %d\n", b
);
1441 printf("b = %d\n", b
);
1445 void bitfield_test(void)
1455 unsigned int f5
: 7;
1457 printf("bitfield_test:");
1458 printf("sizeof(st1) = %d\n", sizeof(st1
));
1467 printf("%d %d %d %d %d\n",
1468 st1
.f1
, st1
.f2
, st1
.f3
, st1
.f4
, st1
.f5
);
1472 printf("st1.f1 == -1\n");
1474 printf("st1.f1 != -1\n");
1476 printf("st1.f2 == -1\n");
1478 printf("st1.f2 != -1\n");
1480 /* bit sizes below must be bigger than 32 since GCC doesn't allow
1481 long-long bitfields whose size is not bigger than int */
1486 unsigned long long f3
: 38;
1488 st2
.f1
= 0x123456789ULL
;
1490 st2
.f2
= (long long)a
<< 25;
1493 printf("%lld %lld %lld\n", st2
.f1
, st2
.f2
, st2
.f3
);
1497 #define FLOAT_FMT "%f\n"
1499 /* x86's float isn't compatible with GCC */
1500 #define FLOAT_FMT "%.5f\n"
1503 /* declare strto* functions as they are C99 */
1504 double strtod(const char *nptr
, char **endptr
);
1505 float strtof(const char *nptr
, char **endptr
);
1506 long double strtold(const char *nptr
, char **endptr
);
1508 #define FTEST(prefix, type, fmt)\
1509 void prefix ## cmp(type a, type b)\
1511 printf("%d %d %d %d %d %d\n",\
1518 printf(fmt " " fmt " " fmt " " fmt " " fmt " " fmt " " fmt "\n",\
1526 printf(fmt "\n", ++a);\
1527 printf(fmt "\n", a++);\
1528 printf(fmt "\n", a);\
1530 printf("%d %d\n", !a, !b);\
1532 void prefix ## fcast(type a)\
1543 printf("ftof: %f %f %Lf\n", fa, da, la);\
1545 ua = (unsigned int)a;\
1546 printf("ftoi: %d %u\n", ia, ua);\
1550 printf("itof: " fmt "\n", b);\
1552 printf("utof: " fmt "\n", b);\
1555 float prefix ## retf(type a) { return a; }\
1556 double prefix ## retd(type a) { return a; }\
1557 long double prefix ## retld(type a) { return a; }\
1559 void prefix ## call(void)\
1561 printf("float: " FLOAT_FMT, prefix ## retf(42.123456789));\
1562 printf("double: %f\n", prefix ## retd(42.123456789));\
1563 printf("long double: %Lf\n", prefix ## retld(42.123456789));\
1564 printf("strto%s: %f\n", #prefix, (double)strto ## prefix("1.2", NULL));\
1567 void prefix ## test(void)\
1569 printf("testing '%s'\n", #type);\
1570 prefix ## cmp(1, 2.5);\
1571 prefix ## cmp(2, 1.5);\
1572 prefix ## cmp(1, 1);\
1573 prefix ## fcast(234.6);\
1574 prefix ## fcast(-2334.6);\
1578 FTEST(f
, float, "%f")
1579 FTEST(d
, double, "%f")
1580 FTEST(ld
, long double, "%Lf")
1582 double ftab1
[3] = { 1.2, 3.4, -5.6 };
1585 void float_test(void)
1592 printf("float_test:\n");
1593 printf("sizeof(float) = %d\n", sizeof(float));
1594 printf("sizeof(double) = %d\n", sizeof(double));
1595 printf("sizeof(long double) = %d\n", sizeof(long double));
1599 printf("%f %f %f\n", ftab1
[0], ftab1
[1], ftab1
[2]);
1600 printf("%f %f %f\n", 2.12, .5, 2.3e10
);
1601 // printf("%f %f %f\n", 0x1234p12, 0x1e23.23p10, 0x12dp-10);
1603 printf("da=%f\n", da
);
1605 printf("fa=%f\n", fa
);
1608 printf("da = %f\n", da
);
1611 printf("db = %f\n", db
);
1619 return fib(n
-1) + fib(n
-2);
1631 printf("funcptr:\n");
1638 /* more complicated pointer computation */
1641 printf("sizeof1 = %d\n", sizeof(funcptr_test
));
1642 printf("sizeof2 = %d\n", sizeof funcptr_test
);
1643 printf("sizeof3 = %d\n", sizeof(&funcptr_test
));
1644 printf("sizeof4 = %d\n", sizeof &funcptr_test
);
1647 void lloptest(long long a
, long long b
)
1649 unsigned long long ua
, ub
;
1654 printf("arith: %Ld %Ld %Ld\n",
1660 printf("arith1: %Ld %Ld\n",
1666 printf("bin: %Ld %Ld %Ld\n",
1672 printf("test: %d %d %d %d %d %d\n",
1680 printf("utest: %d %d %d %d %d %d\n",
1691 printf("arith2: %Ld %Ld\n", a
, b
);
1692 printf("arith2: %Ld %Ld\n", a
++, b
++);
1693 printf("arith2: %Ld %Ld\n", --a
, --b
);
1694 printf("arith2: %Ld %Ld\n", a
, b
);
1696 printf("not: %d %d %d %d\n", !a
, !ua
, !b
, !ub
);
1699 void llshift(long long a
, int b
)
1701 printf("shift: %Ld %Ld %Ld\n",
1702 (unsigned long long)a
>> b
,
1705 printf("shiftc: %Ld %Ld %Ld\n",
1706 (unsigned long long)a
>> 3,
1709 printf("shiftc: %Ld %Ld %Ld\n",
1710 (unsigned long long)a
>> 35,
1720 long long la
, lb
, lc
;
1721 unsigned long long ula
, ulb
, ulc
;
1724 la
= (la
<< 20) | 0x12345;
1726 printf("la=%Ld ula=%Lu\n", la
, ula
);
1731 printf("lltof: %f %f %Lf\n", fa
, da
, lda
);
1736 printf("ftoll: %Ld %Ld %Ld\n", la
, lb
, lc
);
1741 printf("ulltof: %f %f %Lf\n", fa
, da
, lda
);
1746 printf("ftoull: %Lu %Lu %Lu\n", ula
, ulb
, ulc
);
1749 long long llfunc1(int a
)
1759 long long int value(struct S
*v
)
1761 return ((long long int)v
->item
);
1764 void longlong_test(void)
1769 printf("longlong_test:\n");
1770 printf("sizeof(long long) = %d\n", sizeof(long long));
1775 printf("%Ld %Ld\n", a
, b
);
1776 printf("%Ld %Ld %Ld %Lx\n",
1780 0x1234567812345679);
1785 lloptest(0xff, 0x1234);
1786 b
= 0x72345678 << 10;
1790 b
= 0x72345678LL
<< 10;
1801 /* long long reg spill test */
1806 printf("%lld\n", value(&a
));
1808 lloptest(0x80000000, 0);
1810 /* another long long spill test */
1816 printf("%lld\n", *p
);
1821 printf("%d %d %d %d\n", a
> b
, a
< b
, a
>= b
, a
<= b
);
1823 printf("%Ld\n", 0x123456789LLU
);
1826 void manyarg_test(void)
1828 long double ld
= 1234567891234LL;
1829 printf("manyarg_test:\n");
1830 printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\n",
1831 1, 2, 3, 4, 5, 6, 7, 8,
1832 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
1833 printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1835 1, 2, 3, 4, 5, 6, 7, 8,
1836 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1837 1234567891234LL, 987654321986LL,
1839 printf("%Lf %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1841 ld
, 1, 2, 3, 4, 5, 6, 7, 8,
1842 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1843 1234567891234LL, 987654321986LL,
1845 /* XXX: known bug of x86-64 */
1847 printf("%d %d %d %d %d %d %d %d %Lf\n",
1848 1, 2, 3, 4, 5, 6, 7, 8, ld
);
1849 printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1850 "%Ld %Ld %f %f %Lf\n",
1851 1, 2, 3, 4, 5, 6, 7, 8,
1852 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1853 1234567891234LL, 987654321986LL,
1855 printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1856 "%Lf %Ld %Ld %f %f %Lf\n",
1857 1, 2, 3, 4, 5, 6, 7, 8,
1858 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1859 ld
, 1234567891234LL, 987654321986LL,
1864 void vprintf1(const char *fmt
, ...)
1888 i
= va_arg(ap
, int);
1892 d
= va_arg(ap
, double);
1896 ll
= va_arg(ap
, long long);
1900 ld
= va_arg(ap
, long double);
1918 void stdarg_for_struct(struct myspace bob
, ...)
1920 struct myspace george
, bill
;
1925 bill
= va_arg(ap
, struct myspace
);
1926 george
= va_arg(ap
, struct myspace
);
1927 validate
= va_arg(ap
, int);
1928 printf("stdarg_for_struct: %d %d %d %d\n",
1929 bob
.profile
, bill
.profile
, george
.profile
, validate
);
1933 void stdarg_test(void)
1935 long double ld
= 1234567891234LL;
1938 vprintf1("%d %d %d\n", 1, 2, 3);
1939 vprintf1("%f %d %f\n", 1.0, 2, 3.0);
1940 vprintf1("%l %l %d %f\n", 1234567891234LL, 987654321986LL, 3, 1234.0);
1941 vprintf1("%F %F %F\n", 1.2L, 2.3L, 3.4L);
1943 /* a bug of x86's TCC */
1944 vprintf1("%d %f %l %F %d %f %l %F\n",
1945 1, 1.2, 3L, 4.5L, 6, 7.8, 9L, 0.1L);
1947 vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f\n",
1948 1, 2, 3, 4, 5, 6, 7, 8,
1949 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8);
1950 vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\n",
1951 1, 2, 3, 4, 5, 6, 7, 8,
1952 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
1953 vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1955 1, 2, 3, 4, 5, 6, 7, 8,
1956 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1957 1234567891234LL, 987654321986LL,
1959 vprintf1("%F %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1961 ld
, 1, 2, 3, 4, 5, 6, 7, 8,
1962 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1963 1234567891234LL, 987654321986LL,
1965 vprintf1("%d %d %d %d %d %d %d %d %F\n",
1966 1, 2, 3, 4, 5, 6, 7, 8, ld
);
1967 vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1969 1, 2, 3, 4, 5, 6, 7, 8,
1970 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1971 1234567891234LL, 987654321986LL,
1973 vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
1974 "%F %l %l %f %f %F\n",
1975 1, 2, 3, 4, 5, 6, 7, 8,
1976 0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
1977 ld
, 1234567891234LL, 987654321986LL,
1981 stdarg_for_struct(bob
, bob
, bob
, bob
.profile
);
1984 void whitespace_test(void)
1990 ntf("whitspace:\n");\f\v
1994 #ifdef CORRECT_CR_HANDLING
2003 #ifdef ACCEPT_CR_IN_STRINGS
2004 printf("len1=%d\n", strlen("
2006 #ifdef CORRECT_CR_HANDLING
2009 printf("len1=%d str[0]=%d\n", strlen(str
), str
[0]);
2011 printf("len1=%d\n", strlen("
a
2013 #endif /* ACCEPT_CR_IN_STRINGS */
2016 int reltab
[3] = { 1, 2, 3 };
2018 int *rel1
= &reltab
[1];
2019 int *rel2
= &reltab
[2];
2021 void relocation_test(void)
2023 printf("*rel1=%d\n", *rel1
);
2024 printf("*rel2=%d\n", *rel2
);
2027 void old_style_f(a
,b
,c
)
2031 printf("a=%d b=%d b=%f\n", a
, b
, c
);
2034 void decl_func1(int cmpfn())
2036 printf("cmpfn=%lx\n", (long)cmpfn
);
2039 void decl_func2(cmpfn
)
2042 printf("cmpfn=%lx\n", (long)cmpfn
);
2045 void old_style_function(void)
2047 old_style_f((void *)1, 2, 3.0);
2054 #if defined __i386__ || defined __x86_64__
2055 char *p
= alloca(16);
2056 strcpy(p
,"123456789012345");
2057 printf("alloca: p is %s\n", p
);
2058 char *demo
= "This is only a test.\n";
2059 /* Test alloca embedded in a larger expression */
2060 printf("alloca: %s\n", strcpy(alloca(strlen(demo
)+1),demo
) );
2064 void sizeof_test(void)
2069 printf("sizeof(int) = %d\n", sizeof(int));
2070 printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int));
2071 printf("sizeof(long) = %d\n", sizeof(long));
2072 printf("sizeof(unsigned long) = %d\n", sizeof(unsigned long));
2073 printf("sizeof(short) = %d\n", sizeof(short));
2074 printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short));
2075 printf("sizeof(char) = %d\n", sizeof(char));
2076 printf("sizeof(unsigned char) = %d\n", sizeof(unsigned char));
2077 printf("sizeof(func) = %d\n", sizeof sizeof_test());
2079 printf("sizeof(a++) = %d\n", sizeof a
++);
2080 printf("a=%d\n", a
);
2082 printf("sizeof(**ptr) = %d\n", sizeof (**ptr
));
2084 /* some alignof tests */
2085 printf("__alignof__(int) = %d\n", __alignof__(int));
2086 printf("__alignof__(unsigned int) = %d\n", __alignof__(unsigned int));
2087 printf("__alignof__(short) = %d\n", __alignof__(short));
2088 printf("__alignof__(unsigned short) = %d\n", __alignof__(unsigned short));
2089 printf("__alignof__(char) = %d\n", __alignof__(char));
2090 printf("__alignof__(unsigned char) = %d\n", __alignof__(unsigned char));
2091 printf("__alignof__(func) = %d\n", __alignof__
sizeof_test());
2094 void typeof_test(void)
2103 printf("a=%f b=%f c=%f\n", a
, b
, c
);
2106 void statement_expr_test(void)
2119 printf("a=%d\n", a
);
2123 void local_label_test(void)
2129 __label__ l1
, l2
, l3
, l4
;
2143 printf("a=%d\n", a
);
2153 /* inline assembler test */
2156 /* from linux kernel */
2157 static char * strncat1(char * dest
,const char * src
,size_t count
)
2160 __asm__
__volatile__(
2169 "testb %%al,%%al\n\t"
2171 "2:\txorl %2,%2\n\t"
2173 : "=&S" (d0
), "=&D" (d1
), "=&a" (d2
), "=&c" (d3
)
2174 : "0" (src
),"1" (dest
),"2" (0),"3" (0xffffffff), "g" (count
)
2179 static char * strncat2(char * dest
,const char * src
,size_t count
)
2182 __asm__
__volatile__(
2183 "repne scasb\n\t" /* one-line repne prefix + string op */
2190 "testb %%al,%%al\n\t"
2192 "2:\txorl %2,%2\n\t"
2194 : "=&S" (d0
), "=&D" (d1
), "=&a" (d2
), "=&c" (d3
)
2195 : "0" (src
),"1" (dest
),"2" (0),"3" (0xffffffff), "g" (count
)
2200 static inline void * memcpy1(void * to
, const void * from
, size_t n
)
2203 __asm__
__volatile__(
2208 "1:\ttestb $1,%b4\n\t"
2212 : "=&c" (d0
), "=&D" (d1
), "=&S" (d2
)
2213 :"0" (n
/4), "q" (n
),"1" ((long) to
),"2" ((long) from
)
2218 static inline void * memcpy2(void * to
, const void * from
, size_t n
)
2221 __asm__
__volatile__(
2222 "rep movsl\n\t" /* one-line rep prefix + string op */
2226 "1:\ttestb $1,%b4\n\t"
2230 : "=&c" (d0
), "=&D" (d1
), "=&S" (d2
)
2231 :"0" (n
/4), "q" (n
),"1" ((long) to
),"2" ((long) from
)
2236 static __inline__
void sigaddset1(unsigned int *set
, int _sig
)
2238 __asm__("btsl %1,%0" : "=m"(*set
) : "Ir"(_sig
- 1) : "cc");
2241 static __inline__
void sigdelset1(unsigned int *set
, int _sig
)
2243 asm("btrl %1,%0" : "=m"(*set
) : "Ir"(_sig
- 1) : "cc");
2246 static __inline__ __const__
unsigned int swab32(unsigned int x
)
2248 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
2249 "rorl $16,%0\n\t" /* swap words */
2250 "xchgb %b0,%h0" /* swap higher bytes */
2256 static __inline__
unsigned long long mul64(unsigned int a
, unsigned int b
)
2258 unsigned long long res
;
2259 __asm__("mull %2" : "=A" (res
) : "a" (a
), "r" (b
));
2263 static __inline__
unsigned long long inc64(unsigned long long a
)
2265 unsigned long long res
;
2266 __asm__("addl $1, %%eax ; adcl $0, %%edx" : "=A" (res
) : "A" (a
));
2277 printf("inline asm:\n");
2278 /* test the no operand case */
2279 asm volatile ("xorl %eax, %eax");
2281 memcpy1(buf
, "hello", 6);
2282 strncat1(buf
, " worldXXXXX", 3);
2283 printf("%s\n", buf
);
2285 memcpy2(buf
, "hello", 6);
2286 strncat2(buf
, " worldXXXXX", 3);
2287 printf("%s\n", buf
);
2289 /* 'A' constraint test */
2290 printf("mul64=0x%Lx\n", mul64(0x12345678, 0xabcd1234));
2291 printf("inc64=0x%Lx\n", inc64(0x12345678ffffffff));
2294 sigdelset1(&set
, 2);
2295 sigaddset1(&set
, 16);
2296 /* NOTE: we test here if C labels are correctly restored after the
2300 __asm__("btsl %1,%0" : "=m"(set
) : "Ir"(20) : "cc");
2301 #ifdef __GNUC__ // works strange with GCC 4.3
2304 printf("set=0x%x\n", set
);
2306 printf("swab32(0x%08x) = 0x%0x\n", val
, swab32(val
));
2320 #define COMPAT_TYPE(type1, type2) \
2322 printf("__builtin_types_compatible_p(%s, %s) = %d\n", #type1, #type2, \
2323 __builtin_types_compatible_p (type1, type2));\
2328 void builtin_test(void)
2331 COMPAT_TYPE(int, int);
2332 COMPAT_TYPE(int, unsigned int);
2333 COMPAT_TYPE(int, char);
2334 COMPAT_TYPE(int, const int);
2335 COMPAT_TYPE(int, volatile int);
2336 COMPAT_TYPE(int *, int *);
2337 COMPAT_TYPE(int *, void *);
2338 COMPAT_TYPE(int *, const int *);
2339 COMPAT_TYPE(char *, unsigned char *);
2340 /* space is needed because tcc preprocessor introduces a space between each token */
2341 COMPAT_TYPE(char * *, void *);
2343 printf("res = %d\n", __builtin_constant_p(1));
2344 printf("res = %d\n", __builtin_constant_p(1 + 2));
2345 printf("res = %d\n", __builtin_constant_p(&constant_p_var
));
2346 printf("res = %d\n", __builtin_constant_p(constant_p_var
));
2350 extern int __attribute__((weak
)) weak_f1(void);
2351 extern int __attribute__((weak
)) weak_f2(void);
2352 extern int weak_f3(void);
2353 extern int __attribute__((weak
)) weak_v1
;
2354 extern int __attribute__((weak
)) weak_v2
;
2357 extern int (*weak_fpa
)() __attribute__((weak
));
2358 extern int __attribute__((weak
)) (*weak_fpb
)();
2359 extern __attribute__((weak
)) int (*weak_fpc
)();
2361 extern int weak_asm_f1(void) asm("weak_asm_f1x") __attribute((weak
));
2362 extern int __attribute((weak
)) weak_asm_f2(void) asm("weak_asm_f2x") ;
2363 extern int __attribute((weak
)) weak_asm_f3(void) asm("weak_asm_f3x") __attribute((weak
));
2364 extern int weak_asm_v1
asm("weak_asm_v1x") __attribute((weak
));
2365 extern int __attribute((weak
)) weak_asm_v2
asm("weak_asm_v2x") ;
2366 extern int __attribute((weak
)) weak_asm_v3(void) asm("weak_asm_v3x") __attribute((weak
));
2368 static const size_t dummy
= 0;
2369 extern __typeof(dummy
) weak_dummy1
__attribute__((weak
, alias("dummy")));
2370 extern __typeof(dummy
) __attribute__((weak
, alias("dummy"))) weak_dummy2
;
2371 extern __attribute__((weak
, alias("dummy"))) __typeof(dummy
) weak_dummy3
;
2373 void __attribute__((weak
)) weak_test(void)
2375 printf("weak_f1=%d\n", weak_f1
? weak_f1() : 123);
2376 printf("weak_f2=%d\n", weak_f2
? weak_f2() : 123);
2377 printf("weak_f3=%d\n", weak_f3
? weak_f3() : 123);
2378 printf("weak_v1=%d\n",&weak_v1
? weak_v1
: 123);
2379 printf("weak_v2=%d\n",&weak_v2
? weak_v2
: 123);
2380 printf("weak_v3=%d\n",&weak_v3
? weak_v3
: 123);
2382 printf("weak_fpa=%d\n",&weak_fpa
? weak_fpa() : 123);
2383 printf("weak_fpb=%d\n",&weak_fpb
? weak_fpb() : 123);
2384 printf("weak_fpc=%d\n",&weak_fpc
? weak_fpc() : 123);
2386 printf("weak_asm_f1=%d\n", weak_asm_f1
!= NULL
);
2387 printf("weak_asm_f2=%d\n", weak_asm_f2
!= NULL
);
2388 printf("weak_asm_f3=%d\n", weak_asm_f3
!= NULL
);
2389 printf("weak_asm_v1=%d\n",&weak_asm_v1
!= NULL
);
2390 printf("weak_asm_v2=%d\n",&weak_asm_v2
!= NULL
);
2391 printf("weak_asm_v3=%d\n",&weak_asm_v3
!= NULL
);
2394 int __attribute__((weak
)) weak_f2() { return 222; }
2395 int __attribute__((weak
)) weak_f3() { return 333; }
2396 int __attribute__((weak
)) weak_v2
= 222;
2397 int __attribute__((weak
)) weak_v3
= 333;
2399 void const_func(const int a
)
2403 void const_warn_test(void)