]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/Wstringop-overflow-47.c
1 /* Verify that storing a bigger vector into smaller space is diagnosed.
3 { dg-options "-O2" } */
5 typedef __INT16_TYPE__
int16_t;
6 typedef __attribute__ ((__vector_size__ (32))) char C32
;
8 typedef __attribute__ ((__vector_size__ (64))) int16_t I16_64
;
13 void nowarn_c32 (char c
)
15 extern char nowarn_a32
[32];
18 *(C32
*)p
= (C32
){ c
};
23 *(C32
*)p
= (C32
){ c
};
27 /* The tests below failed as a result of the hack for PR 96963. However,
28 with -Wall, the invalid stores were diagnosed by -Warray-bounds which
29 runs before vectorization and so doesn't need the hack. Now that
30 -Warray-bounds has changed to use compute_objsize() the tests pass. */
32 void warn_c32 (char c
)
34 extern char warn_a32
[32]; // { dg-message "at offset 32 into destination object 'warn_a32' of size 32" "pr97027" }
36 void *p
= warn_a32
+ 1;
37 *(C32
*)p
= (C32
){ c
}; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" }
39 /* Verify a local variable too. */
42 *(C32
*)p
= (C32
){ c
}; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" }
47 void nowarn_i16_64 (int16_t i
)
49 extern char nowarn_a64
[64];
52 I16_64
*q
= (I16_64
*)p
;
61 void warn_i16_64 (int16_t i
)
63 extern char warn_a64
[64]; // { dg-message "at offset 128 to object 'warn_a64' with size 64" "pr97027" { xfail *-*-* } }
65 void *p
= warn_a64
+ 1;
66 I16_64
*q
= (I16_64
*)p
;
67 *q
= (I16_64
){ i
}; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" { xfail *-*-* } }
72 *q
= (I16_64
){ i
}; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" { xfail *-*-* } }