comparison gcc/testsuite/gcc.c-torture/execute/pr82524.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* PR target/82524 */
2
3 struct S { unsigned char b, g, r, a; };
4 union U { struct S c; unsigned v; };
5
6 static inline unsigned char
7 foo (unsigned char a, unsigned char b)
8 {
9 return ((a + 1) * b) >> 8;
10 }
11
12 __attribute__((noinline, noclone)) unsigned
13 bar (union U *x, union U *y)
14 {
15 union U z;
16 unsigned char v = x->c.a;
17 unsigned char w = foo (y->c.a, 255 - v);
18 z.c.r = foo (x->c.r, v) + foo (y->c.r, w);
19 z.c.g = foo (x->c.g, v) + foo (y->c.g, w);
20 z.c.b = foo (x->c.b, v) + foo (y->c.b, w);
21 z.c.a = 0;
22 return z.v;
23 }
24
25 int
26 main ()
27 {
28 union U a, b, c;
29 if ((unsigned char) ~0 != 255 || sizeof (unsigned) != 4)
30 return 0;
31 a.c = (struct S) { 255, 255, 255, 0 };
32 b.c = (struct S) { 255, 255, 255, 255 };
33 c.v = bar (&a, &b);
34 if (c.c.b != 255 || c.c.g != 255 || c.c.r != 255 || c.c.a != 0)
35 __builtin_abort ();
36 return 0;
37 }