1 /* PR middle-end/93200 - spurious -Wstringop-overflow due to assignment
2    vectorization to multiple members
3    { dg-do compile }
4    { dg-options "-O3 -Wall" } */
5 
6 typedef __INT8_TYPE__  int8_t;
7 typedef __INT16_TYPE__ int16_t;
8 typedef __INT32_TYPE__ int32_t;
9 typedef __INT64_TYPE__ int64_t;
10 
11 struct A { char b, c; };
12 struct B1A { int8_t i8; struct A a; };
13 struct B2A { int16_t i16; struct A a; };
14 struct B3A { int16_t i16; int8_t i8; struct A a; };
15 struct B4A { int64_t i64; struct A a; };
16 
ba1(struct B1A * p)17 void ba1 (struct B1A *p)
18 {
19   p->a.b = 0; p->a.c = 1;
20 }
21 
b2a(struct B2A * p)22 void b2a (struct B2A *p)
23 {
24   /* This results in:
25      vector(2) char *vectp.14_6 = &p_2(D)->a.b;
26      MEM <vector(2) char> [(char *)vectp.14_6] = { 4, 5 };  */
27 
28   p->a.b = 4;       // { dg-bogus "-Wstringop-overflow" }
29   p->a.c = 5;
30 }
31 
b3a(struct B3A * p)32 void b3a (struct B3A *p)
33 {
34   p->a.b = 4; p->a.c = 5;
35 }
36 
b4a(struct B4A * p)37 void b4a (struct B4A *p)
38 {
39   /* This results in:
40      vector(2) char *vectp.22_6 = &p_2(D)->a.b;
41      MEM <vector(2) char> [(char *)vectp.22_6] = { 6, 7 };  */
42 
43   p->a.b = 6;       // { dg-bogus "-Wstringop-overflow" }
44   p->a.c = 7;
45 }
46 
47 
48 struct Aa { char a[2], b[2]; };
49 struct B1Aa { int8_t i8; struct Aa a; };
50 struct B2Aa { int16_t i16; struct Aa a; };
51 struct B3Aa { int16_t i16; int8_t i8; struct Aa a; };
52 struct B4Aa { int64_t i64; struct Aa a; };
53 
b1aa(struct B1Aa * p)54 void b1aa (struct B1Aa *p)
55 {
56   p->a.a[0] = 0; p->a.a[1] = 1;
57   p->a.b[0] = 0; p->a.b[1] = 1;
58 }
59 
b2aa(struct B2Aa * p)60 void b2aa (struct B2Aa *p)
61 {
62   p->a.a[0] = 2; p->a.a[1] = 3;
63   p->a.b[0] = 2; p->a.b[1] = 3;
64 }
65 
b3aa(struct B3Aa * p)66 void b3aa (struct B3Aa *p)
67 {
68   p->a.a[0] = 4; p->a.a[1] = 5;
69   p->a.b[0] = 4; p->a.b[1] = 5;
70 }
71 
b4aa(struct B4Aa * p)72 void b4aa (struct B4Aa *p)
73 {
74   /* This results in:
75      vector(4) char *vectp.36_8 = &p_2(D)->a.a[0];
76      MEM <vector(4) char> [(char *)vectp.36_8] = { 6, 7, 6, 7 };  */
77 
78   p->a.a[0] = 6; p->a.a[1] = 7;
79   p->a.b[0] = 6; p->a.b[1] = 7;
80 }
81