tcc -MD: drop system includes and duplicates
[tinycc.git] / tests / tests2 / 96_nodata_wanted.c
blob790b4313cc09b5090772ffba70004a31d6331d4e
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_off || defined test_data_suppression_on
30 #if defined test_data_suppression_on
31 # define SKIP 1
32 #else
33 # define SKIP 0
34 #endif
36 #include <stdio.h>
37 /* some gcc headers #define __attribute__ to empty if it's not gcc */
38 #undef __attribute__
40 int main()
42 __label__ ts0, te0, ts1, te1;
43 int tl, dl;
45 static char ds0 = 0;
46 static char de0 = 0;
47 /* get reference size of empty jmp */
48 ts0:;
49 if (!SKIP) {}
50 te0:;
51 dl = -(&de0 - &ds0);
52 tl = -(&&te0 - &&ts0);
54 /* test data and code suppression */
55 static char ds1 = 0;
56 ts1:;
57 if (!SKIP) {
58 void *p = (void*)&main;
59 char cc[] = "static string";
60 double d = 8.0;
61 struct __attribute__((packed)) {
62 unsigned x : 12;
63 unsigned char y : 7;
64 unsigned z : 28, a: 4, b: 5;
65 } s = { 0x333,0x44,0x555555,6,7 };
67 printf("data:\n");
68 printf(" %d - %.1f - %.1f - %s - %s\n",
69 sizeof 8.0, 8.0, d, __FUNCTION__, cc);
70 printf(" %x %x %x %x %x\n",
71 s.x, s.y, s.z, s.a, s.b);
73 te1:;
74 static char de1 = 0;
76 dl += &de1 - &ds1;
77 tl += &&te1 - &&ts1;
78 printf("size of data/text:\n %s/%s\n",
79 dl ? "non-zero":"zero", tl ? "non-zero":"zero");
80 /*printf("# %d/%d\n", dl, tl);*/
83 #elif defined test_static_data
85 #include <stdio.h>
86 int main(int argc, char **argv)
88 goto there;
89 if (0) {
90 static int a = 1;
91 printf("hello\n"); /* the "hello\n" string is still suppressed */
92 there:
93 printf("a = %d\n", a);
95 return 0;
98 #endif