]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/c-c++-common/ubsan/nonnull-2.c
New syntax for -fsanitize-recover.
[gcc.git] / gcc / testsuite / c-c++-common / ubsan / nonnull-2.c
CommitLineData
126edc3f
JJ
1/* { dg-do run } */
2/* { dg-shouldfail "ubsan" } */
d95a2703 3/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */
126edc3f
JJ
4
5int q, r;
6void *a, *b, *c = (void *) &q, *d, *e, *f = (void *) &q, *g, *h;
7
8__attribute__((returns_nonnull, nonnull (1, 3)))
9void *
10foo (void *p, void *q, void *r)
11{
12 a = p;
13 b = r;
14 return q;
15}
16
17int
18bar (const void *a, const void *b)
19{
20 int c = *(const int *) a;
21 int d = *(const int *) b;
22 return c - d;
23}
24
25int
26main ()
27{
28 asm volatile ("" : : : "memory");
29 d = foo (c, b, c);
30 e = foo (e, c, f);
31 g = foo (c, f, g);
32 __builtin_memset (d, '\0', q);
33 return 0;
34}
35
36/* { dg-output "\.c:14:\[0-9]*:\[^\n\r]*null pointer returned from function declared to never return null" } */
This page took 0.12758 seconds and 5 git commands to generate.