OSDN Git Service

* gcc.dg/pr34856.c: Ignore irrelevant warning.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / pr11864-1.c
1 /* PR optimization/11864
2  * Reporter: Kazumoto Kojima <kkojima@gcc.gnu.org>
3  * Summary: [3.3/3.4 regression] miscompiles zero extension and test
4  * Description:
5  * gcc-3.3/3.4 -O2 for sh target may miscompile the combination of zero extension
6  * and test if it's zero.
7  *
8  * Testcase tweaked by dank@kegel.com.  Not marked as xfail because it's a regression.
9  */
10 /* { dg-do run } */
11 /* { dg-options "-O2" } */
12
13 extern void abort(void);
14
15 int val = 0xff00;
16
17 int f(void)
18 {
19         return val;
20 }
21
22 unsigned char a[1];
23
24 void foo(void)
25 {
26         a[0] = f() & 255;
27
28         if (!a[0])
29                 a[0] = f() & 255;
30
31         if (!a[0])
32                 a[0] = 1 + (f() & 127);
33 }
34
35 int main(int argc, char **argv)
36 {
37         foo();
38         if (!a[0])
39                 abort();
40
41         return 0;
42 }