tcc -dt -run ... : simpler is better
[tinycc.git] / tests / tests2 / 96_nodata_wanted.c
blob1f022c9d1b7db844f9f227fdd0f327a32c2ab131
1 /*****************************************************************************/
2 /* test 'nodata_wanted' data output suppression */
4 #if defined test_static_data_error
5 void foo() {
6 if (1) {
7 static short w = (int)&foo; /* initializer not computable */
11 #elif defined test_static_nodata_error
12 void foo() {
13 if (0) {
14 static short w = (int)&foo; /* initializer not computable */
18 #elif defined test_global_data_error
19 void foo();
20 static short w = (int)&foo; /* initializer not computable */
23 #elif defined test_local_data_noerror
24 void foo() {
25 short w = &foo; /* 2 cast warnings */
28 #elif defined test_data_suppression
29 #include <stdio.h>
31 #define ASMLABELS(s) \
32 __asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n")
34 #define PROG \
35 static void *p = (void*)&main;\
36 static char cc[] = "static string";\
37 static double d = 8.0;\
38 static struct __attribute__((packed)) {\
39 unsigned x : 12;\
40 unsigned char y : 7;\
41 unsigned z : 28, a: 4, b: 5;\
42 } s = { 0x333,0x44,0x555555,6,7 };\
43 printf(" static data: %d - %.1f - %.1f - %s - %s\n",\
44 sizeof 8.0, 8.0, d, __FUNCTION__, cc);\
45 printf(" static bitfields: %x %x %x %x %x\n", s.x, s.y, s.z, s.a, s.b);
47 int main()
49 extern char ds1[],ts1[];
50 extern char ds2[],ts2[];
51 extern char de1[],te1[];
52 extern char de2[],te2[];
54 printf("suppression off\n");
55 if (1) {
56 ASMLABELS(s1);
57 PROG
58 ASMLABELS(e1);
60 printf(" data length is %s\n", de1 - ds1 ? "not 0":"0");
61 printf(" text length is %s\n", te1 - ts1 ? "not 0":"0");
63 printf("suppression on\n");
64 if (0) {
65 ASMLABELS(s2);
66 PROG
67 ASMLABELS(e2);
69 printf(" data length is %x\n", de2 - ds2);
70 printf(" text length is %X\n", te2 - ts2);
71 return 0;
74 #endif