RISC-V: Add testcases for unsigned .SAT_ADD vector form 8
[official-gcc.git] / gcc / testsuite / gcc.dg / pr36902.c
blob365a26e26b70cb846ddb1ad4d68437fb8164cb37
1 /* PR middle-end/36902 Array bound warning with dead code after optimization */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Warray-bounds -Wall -Wextra" } */
4 typedef unsigned char __u8;
5 typedef unsigned short __u16;
7 static inline unsigned char *
8 foo(unsigned char * to, const unsigned char * from, int n)
10 switch ( n )
12 case 3:
13 *to = *from;
14 break;
15 case 5:
16 to[4] = from [4];
17 break;
19 return to;
22 struct {
23 int size_of_select;
24 unsigned char pcr_select[4];
25 } sel;
27 unsigned char buf[64];
28 int bar(void)
30 sel.size_of_select = 3;
31 foo(buf, sel.pcr_select, sel.size_of_select);
33 return 1;
37 static inline unsigned char *
38 foo2(unsigned char * to, const unsigned char * from, int n)
40 switch ( n )
42 case 3:
43 *to = *from;
44 break;
45 case 5:
46 to[4] = from [4]; /* { dg-warning "\\\[-Warray-bounds" } */
47 break;
49 return to;
52 int baz(void)
54 sel.size_of_select = 5;
55 foo2(buf, sel.pcr_select, sel.size_of_select);
57 return 1;