* gcc.c-torture/execute/20101011-1.c: Skip on SH.
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20010122-1.c
blob280e3d45c9eb3cc64466c57e3b24d2ab5aa3f68f
2 extern void exit (int);
3 extern void abort (void);
4 extern void *alloca (__SIZE_TYPE__);
5 char *dummy (void);
7 #define NOINLINE __attribute__((noinline))
9 void *save_ret1[6];
10 void *test4a (char *);
11 void *test5a (char *);
12 void *test6a (char *);
14 void NOINLINE *test1 (void)
16 void * temp;
17 temp = __builtin_return_address (0);
18 return temp;
21 void NOINLINE *test2 (void)
23 void * temp;
24 dummy ();
25 temp = __builtin_return_address (0);
26 return temp;
29 void NOINLINE *test3 (void)
31 void * temp;
32 temp = __builtin_return_address (0);
33 dummy ();
34 return temp;
37 void NOINLINE *test4 (void)
39 char * save = (char*) alloca (4);
41 return test4a (save);
44 void *NOINLINE test4a (char * p)
46 void * temp;
47 temp = __builtin_return_address (1);
48 return temp;
51 void NOINLINE *test5 (void)
53 char * save = (char*) alloca (4);
55 return test5a (save);
58 void NOINLINE *test5a (char * p)
60 void * temp;
61 dummy ();
62 temp = __builtin_return_address (1);
63 return temp;
66 void NOINLINE *test6 (void)
68 char * save = (char*) alloca (4);
70 return test6a (save);
73 void NOINLINE *test6a (char * p)
75 void * temp;
76 temp = __builtin_return_address (1);
77 dummy ();
78 return temp;
81 void *(*func1[6])(void) = { test1, test2, test3, test4, test5, test6 };
83 char * NOINLINE call_func1 (int i)
85 save_ret1[i] = func1[i] ();
88 static void *ret_addr;
89 void *save_ret2[6];
90 void test10a (char *);
91 void test11a (char *);
92 void test12a (char *);
94 void NOINLINE test7 (void)
96 ret_addr = __builtin_return_address (0);
97 return;
100 void NOINLINE test8 (void)
102 dummy ();
103 ret_addr = __builtin_return_address (0);
104 return;
107 void NOINLINE test9 (void)
109 ret_addr = __builtin_return_address (0);
110 dummy ();
111 return;
114 void NOINLINE test10 (void)
116 char * save = (char*) alloca (4);
118 test10a (save);
121 void NOINLINE test10a (char * p)
123 ret_addr = __builtin_return_address (1);
124 return;
127 void NOINLINE test11 (void)
129 char * save = (char*) alloca (4);
131 test11a (save);
134 void NOINLINE test11a (char * p)
136 dummy ();
137 ret_addr = __builtin_return_address (1);
138 return;
141 void NOINLINE test12 (void)
143 char * save = (char*) alloca (4);
145 test12a (save);
148 void NOINLINE test12a (char * p)
150 ret_addr = __builtin_return_address (1);
151 dummy ();
152 return;
155 char * dummy (void)
157 char * save = (char*) alloca (4);
159 return save;
162 void (*func2[6])(void) = { test7, test8, test9, test10, test11, test12 };
164 void NOINLINE call_func2 (int i)
166 func2[i] ();
167 save_ret2[i] = ret_addr;
170 int main (void)
172 int i;
174 for (i = 0; i < 6; i++) {
175 call_func1(i);
178 if (save_ret1[0] != save_ret1[1]
179 || save_ret1[1] != save_ret1[2])
180 abort ();
181 if (save_ret1[3] != save_ret1[4]
182 || save_ret1[4] != save_ret1[5])
183 abort ();
184 if (save_ret1[3] && save_ret1[0] != save_ret1[3])
185 abort ();
188 for (i = 0; i < 6; i++) {
189 call_func2(i);
192 if (save_ret2[0] != save_ret2[1]
193 || save_ret2[1] != save_ret2[2])
194 abort ();
195 if (save_ret2[3] != save_ret2[4]
196 || save_ret2[4] != save_ret2[5])
197 abort ();
198 if (save_ret2[3] && save_ret2[0] != save_ret2[3])
199 abort ();
201 exit (0);