2017-07-16 18:10:00 +08:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* test 'nodata_wanted' data output suppression */
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#if defined test_static_data_error
|
2017-07-16 18:10:00 +08:00
|
|
|
void foo() {
|
|
|
|
if (1) {
|
2017-07-21 04:21:27 +08:00
|
|
|
static short w = (int)&foo; /* initializer not computable */
|
2017-07-16 18:10:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#elif defined test_static_nodata_error
|
2017-07-16 18:10:00 +08:00
|
|
|
void foo() {
|
|
|
|
if (0) {
|
2017-07-21 04:21:27 +08:00
|
|
|
static short w = (int)&foo; /* initializer not computable */
|
2017-07-16 18:10:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#elif defined test_global_data_error
|
2017-07-16 18:10:00 +08:00
|
|
|
void foo();
|
2017-07-21 04:21:27 +08:00
|
|
|
static short w = (int)&foo; /* initializer not computable */
|
2017-07-16 18:10:00 +08:00
|
|
|
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#elif defined test_local_data_noerror
|
2017-07-16 18:10:00 +08:00
|
|
|
void foo() {
|
2017-07-21 04:21:27 +08:00
|
|
|
short w = &foo; /* 2 cast warnings */
|
2017-07-16 18:10:00 +08:00
|
|
|
}
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#elif defined test_data_suppression
|
2017-07-16 18:10:00 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#define ASMLABELS(s) \
|
|
|
|
__asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n")
|
2017-07-16 18:10:00 +08:00
|
|
|
|
|
|
|
#define PROG \
|
|
|
|
static void *p = (void*)&main;\
|
|
|
|
static char cc[] = "static string";\
|
|
|
|
static double d = 8.0;\
|
|
|
|
static struct __attribute__((packed)) {\
|
|
|
|
unsigned x : 12;\
|
|
|
|
unsigned char y : 7;\
|
|
|
|
unsigned z : 28, a: 4, b: 5;\
|
|
|
|
} s = { 0x333,0x44,0x555555,6,7 };\
|
|
|
|
printf(" static data: %d - %.1f - %.1f - %s - %s\n",\
|
|
|
|
sizeof 8.0, 8.0, d, __FUNCTION__, cc);\
|
|
|
|
printf(" static bitfields: %x %x %x %x %x\n", s.x, s.y, s.z, s.a, s.b);
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2017-07-21 04:21:27 +08:00
|
|
|
extern char ds1[],ts1[];
|
|
|
|
extern char ds2[],ts2[];
|
|
|
|
extern char de1[],te1[];
|
|
|
|
extern char de2[],te2[];
|
|
|
|
|
2017-07-16 18:10:00 +08:00
|
|
|
printf("suppression off\n");
|
|
|
|
if (1) {
|
2017-07-21 04:21:27 +08:00
|
|
|
ASMLABELS(s1);
|
2017-07-16 18:10:00 +08:00
|
|
|
PROG
|
2017-07-21 04:21:27 +08:00
|
|
|
ASMLABELS(e1);
|
2017-07-16 18:10:00 +08:00
|
|
|
}
|
|
|
|
printf(" data length is %s\n", de1 - ds1 ? "not 0":"0");
|
2017-07-21 04:21:27 +08:00
|
|
|
printf(" text length is %s\n", te1 - ts1 ? "not 0":"0");
|
2017-07-16 18:10:00 +08:00
|
|
|
|
|
|
|
printf("suppression on\n");
|
|
|
|
if (0) {
|
2017-07-21 04:21:27 +08:00
|
|
|
ASMLABELS(s2);
|
2017-07-16 18:10:00 +08:00
|
|
|
PROG
|
2017-07-21 04:21:27 +08:00
|
|
|
ASMLABELS(e2);
|
2017-07-16 18:10:00 +08:00
|
|
|
}
|
|
|
|
printf(" data length is %x\n", de2 - ds2);
|
2017-07-21 04:21:27 +08:00
|
|
|
printf(" text length is %X\n", te2 - ts2);
|
2017-07-16 18:10:00 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-21 04:21:27 +08:00
|
|
|
#endif
|