source: EcnlProtoTool/trunk/tcc-0.9.27/tests/tests2/96_nodata_wanted.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 1.9 KB
Line 
1/*****************************************************************************/
2/* test 'nodata_wanted' data output suppression */
3
4#if defined test_static_data_error
5void foo() {
6 if (1) {
7 static short w = (int)&foo; /* initializer not computable */
8 }
9}
10
11#elif defined test_static_nodata_error
12void foo() {
13 if (0) {
14 static short w = (int)&foo; /* initializer not computable */
15 }
16}
17
18#elif defined test_global_data_error
19void foo();
20static short w = (int)&foo; /* initializer not computable */
21
22
23#elif defined test_local_data_noerror
24void 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
40int 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 */
48ts0:;
49 if (!SKIP) {}
50te0:;
51 dl = -(&de0 - &ds0);
52 tl = -(&&te0 - &&ts0);
53
54 /* test data and code suppression */
55 static char ds1 = 0;
56ts1:;
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 }
74te1:;
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
Note: See TracBrowser for help on using the repository browser.