1 /* Verify warnings and notes for MAX_EXPRs involving either pointers
2 to distinct objects or one to a known object and the other to
3 an unknown one. Unlike for the same object, for unrelated objects
4 the expected warnings and notes are the same as for MIN_EXPR: when
5 the order of the objects in the address space cannot be determined
6 the larger of them is assumed to be used. (This is different for
7 distinct struct members where the order is given.)
8 The relational expressions are strictly invalid but that should be
9 diagnosed by a separate warning.
11 { dg-options "-O2 -Wno-array-bounds" } */
13 #define MAX(p, q) ((p) > (q) ? (p) : (q))
15 /* Verify that even for MAX_EXPR and like for MIN_EXPR, the note points
16 to the larger of the two objects and mentions the offset into it
17 (although the offset might be better included in the warning). */
19 extern char a5
[5]; // { dg-message "at offset \[^a-zA-Z\n\r\]*5\[^a-zA-Z0-9\]* into destination object 'a5' of size 5" "note" }
21 void max_a3_a5 (int i
)
26 /* The relational expression below is invalid and should be diagnosed
27 by its own warning independently of -Wstringop-overflow. */
30 d
[2] = 0; // { dg-warning "writing 4 bytes into a region of size 3" "pr102706" { target { vect_slp_v4qi_store_unalign } } }
33 d
[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102706" { xfail { vect_slp_v4qi_store_unalign } } }
37 // Same as above but with the larger array as the first MAX_EXPR operand.
39 extern char b6
[6]; // { dg-message "at offset \[^a-zA-Z\n\r\]*6\[^a-zA-Z0-9\]* into destination object 'b6' of size 6" "note" }
41 void max_b6_b4 (int i
)
47 d
[3] = 0; // { dg-warning "writing 4 bytes into a region of size 3" "pr102706" { target { vect_slp_v4qi_store_unalign } } }
50 d
[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102706" { xfail { vect_slp_v4qi_store_unalign } } }
54 /* Same as above but with the first MAX_EXPR operand pointing to an unknown
56 extern char c7
[7]; // { dg-message "at offset 7 into destination object 'c7' of size 7" "note" { xfail { vect_slp_v2qi_store_unalign } } }
58 void max_p_c7 (char *p
, int i
)
63 d
[6] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } }
64 d
[7] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } }
68 /* Same as above but with the second MIN_EXPR operand pointing to an unknown
70 extern char d8
[8]; // { dg-message "at offset 8 into destination object 'd8' of size 8" "note" { xfail { vect_slp_v2qi_store_unalign } } }
72 void max_d8_p (char *q
, int i
)
77 d
[7] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } }
78 d
[8] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } }
84 char a3
[3]; // { dg-message "at offset 3 into destination object 'a3' of size 3" "pr??????" { xfail *-*-* } }
85 // refer to pr102697 for xfail
86 char a5
[5]; // { dg-message "at offset 5 into destination object 'a5' of size 5" "note" { xfail { vect_slp_v4qi_store_unalign } } }
89 void max_A3_A5 (int i
, struct A3_5
*pa3_5
)
91 char *p
= pa3_5
->a3
+ i
;
92 char *q
= pa3_5
->a5
+ i
;
97 d
[3] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr??????" { xfail *-*-* } }
99 d
[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102697" { xfail { vect_slp_v4qi_store_unalign } } }
106 // refer to pr102697 for xfail
107 char b6
[6]; // { dg-message "at offset \[^a-zA-Z\n\r\]*6\[^a-zA-Z0-9\]* into destination object 'b6' of size 6" "note" { xfail { vect_slp_v4qi_store_unalign } } }
110 void max_B6_B4 (int i
, struct B4_B6
*pb4_b6
)
112 char *p
= pb4_b6
->b6
+ i
;
113 char *q
= pb4_b6
->b4
+ i
;
114 char *d
= MAX (p
, q
);
119 d
[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102697" { xfail { vect_slp_v4qi_store_unalign } } }
125 char c7
[7]; // { dg-message "at offset 7 into destination object 'c7' of size 7" "note" { xfail { vect_slp_v2qi_store_unalign } } }
128 void max_p_C7 (char *p
, int i
, struct C7
*pc7
)
130 char *q
= pc7
->c7
+ i
;
131 char *d
= MAX (p
, q
);
134 d
[7] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } }
140 char d8
[8]; // { dg-message "at offset 8 into destination object 'd8' of size 8" "note" { xfail { vect_slp_v2qi_store_unalign } } }
143 void max_D8_p (char *q
, int i
, struct D8
*pd8
)
145 char *p
= pd8
->d8
+ i
;
146 char *d
= MAX (p
, q
);
149 d
[8] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } }