Revise -mdisable-fpregs option and add new -msoft-mult option
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-65.c
blob9f82d73e3114c0fda0f4971dae2dc7c356df3bde
1 /* PR middle-end/96963 - -Wstringop-overflow false positive with
2 -ftree-vectorize when assigning consecutive char struct members
3 { dg-do compile }
4 { dg-options "-O2 -Wall -ftree-vectorize" } */
6 void sink (void*);
8 struct Char
10 int i;
11 char c, d, e, f;
12 char a[2], b[2];
15 void nowarn_char_assign (struct Char *p)
17 sink (&p->c);
19 /* Verify the bogus warning triggered by the tree-ssa-strlen.c pass
20 is not issued. */
21 p->c = 1; // { dg-bogus "\\\[-Wstringop-overflow" }
22 p->d = 2;
23 p->e = 3;
24 p->f = 4;
27 void nowarn_char_array_assign (struct Char *p)
29 sink (p->a);
31 p->a[0] = 1; // { dg-bogus "\\\[-Wstringop-overflow" }
32 p->a[1] = 2;
33 p->b[0] = 3;
34 p->b[1] = 4;
37 void warn_char_array_assign_interior (struct Char *p)
39 sink (p->a);
41 p->a[0] = 1;
42 p->a[1] = 2;
43 #pragma GCC diagnostic push
44 #pragma GCC diagnostic ignored "-Warray-bounds"
45 /* Warnings are only suppressed for trailing arrays. Verify
46 one is issued for an interior array. */
47 p->a[2] = 5; // { dg-warning "\\\[-Wstringop-overflow" }
48 #pragma GCC diagnostic pop
51 void warn_char_array_assign_trailing (struct Char *p)
53 /* This is separated from warn_char_array_assign_interior because
54 otherwise GCC removes the store to p->a[2] as dead since it's
55 overwritten by p->b[0]. */
56 sink (p->b);
58 p->b[0] = 3;
59 p->b[1] = 4;
60 #pragma GCC diagnostic push
61 #pragma GCC diagnostic ignored "-Warray-bounds"
62 /* Warnings are only suppressed for trailing arrays with at most
63 one element. Verify one is issued for a two-element array. */
64 p->b[2] = 5; // { dg-warning "\\\[-Wstringop-overflow" }
65 #pragma GCC diagnostic pop
69 /* Also verify there's no warning for other types than char (even though
70 the problem was limited to chars and -Wstringop-overflow should only
71 trigger for character accesses). */
73 struct Short
75 int i;
76 short c, d, e, f;
77 short a[2], b[2];
80 void nowarn_short_assign (struct Short *p)
82 sink (&p->c);
84 p->c = 1;
85 p->d = 2;
86 p->e = 3;
87 p->f = 4;
90 void nowarn_short_array_assign (struct Short *p)
92 sink (p->a);
94 p->a[0] = 1;
95 p->a[1] = 2;
96 p->b[0] = 3;
97 p->b[1] = 4;