[331] | 1 | /*****************************************************************************/
|
---|
| 2 | /* test 'nodata_wanted' data output suppression */
|
---|
| 3 |
|
---|
| 4 | #if defined test_static_data_error
|
---|
| 5 | void foo() {
|
---|
| 6 | if (1) {
|
---|
| 7 | static short w = (int)&foo; /* initializer not computable */
|
---|
| 8 | }
|
---|
| 9 | }
|
---|
| 10 |
|
---|
| 11 | #elif defined test_static_nodata_error
|
---|
| 12 | void foo() {
|
---|
| 13 | if (0) {
|
---|
| 14 | static short w = (int)&foo; /* initializer not computable */
|
---|
| 15 | }
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | #elif defined test_global_data_error
|
---|
| 19 | void foo();
|
---|
| 20 | static short w = (int)&foo; /* initializer not computable */
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | #elif defined test_local_data_noerror
|
---|
| 24 | void foo() {
|
---|
| 25 | short w = &foo; /* 2 cast warnings */
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | #elif defined test_data_suppression_off || defined test_data_suppression_on
|
---|
| 29 |
|
---|
| 30 | #if defined test_data_suppression_on
|
---|
| 31 | # define SKIP 1
|
---|
| 32 | #else
|
---|
| 33 | # define SKIP 0
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
| 36 | #include <stdio.h>
|
---|
| 37 | /* some gcc headers #define __attribute__ to empty if it's not gcc */
|
---|
| 38 | #undef __attribute__
|
---|
| 39 |
|
---|
| 40 | int main()
|
---|
| 41 | {
|
---|
| 42 | __label__ ts0, te0, ts1, te1;
|
---|
| 43 | int tl, dl;
|
---|
| 44 |
|
---|
| 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);
|
---|
| 53 |
|
---|
| 54 | /* test data and code suppression */
|
---|
| 55 | static char ds1 = 0;
|
---|
| 56 | ts1:;
|
---|
| 57 | if (!SKIP) {
|
---|
| 58 | static void *p = (void*)&main;
|
---|
| 59 | static char cc[] = "static string";
|
---|
| 60 | static double d = 8.0;
|
---|
| 61 |
|
---|
| 62 | static struct __attribute__((packed)) {
|
---|
| 63 | unsigned x : 12;
|
---|
| 64 | unsigned char y : 7;
|
---|
| 65 | unsigned z : 28, a: 4, b: 5;
|
---|
| 66 | } s = { 0x333,0x44,0x555555,6,7 };
|
---|
| 67 |
|
---|
| 68 | printf("data:\n");
|
---|
| 69 | printf(" %d - %.1f - %.1f - %s - %s\n",
|
---|
| 70 | sizeof 8.0, 8.0, d, __FUNCTION__, cc);
|
---|
| 71 | printf(" %x %x %x %x %x\n",
|
---|
| 72 | s.x, s.y, s.z, s.a, s.b);
|
---|
| 73 | }
|
---|
| 74 | te1:;
|
---|
| 75 | static char de1 = 0;
|
---|
| 76 |
|
---|
| 77 | dl += &de1 - &ds1;
|
---|
| 78 | tl += &&te1 - &&ts1;
|
---|
| 79 | printf("size of data/text:\n %s/%s\n",
|
---|
| 80 | dl ? "non-zero":"zero", tl ? "non-zero":"zero");
|
---|
| 81 | /*printf("# %d/%d\n", dl, tl);*/
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | #endif
|
---|