Disable gnat.dg/socket1.adb on hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / nonnull-1.c
blobd3063ca4a6fcb890186e3fcd152ac63fc1a3cb40
1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=nonnull-attribute,returns-nonnull-attribute" } */
4 int q, r;
5 void *a, *b, *c = (void *) &q, *d, *e, *f = (void *) &q, *g, *h;
7 __attribute__((returns_nonnull, nonnull (1, 3)))
8 void *
9 foo (void *p, void *q, void *r)
11 a = p;
12 b = r;
13 return q;
16 int
17 bar (const void *a, const void *b)
19 int c = *(const int *) a;
20 int d = *(const int *) b;
21 return c - d;
24 int
25 main ()
27 asm volatile ("" : : : "memory");
28 d = foo (c, b, c);
29 e = foo (e, c, f);
30 g = foo (c, f, g);
31 __builtin_memset (d, '\0', q);
32 return 0;
35 /* { dg-output "\.c:13:\[0-9]*:\[^\n\r]*null pointer returned from function declared to never return null\[^\n\r]*(\n|\r\n|\r)" } */
36 /* { dg-output "\[^\n\r]*\.c:29:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
37 /* { dg-output "\[^\n\r]*\.c:30:\[0-9]*:\[^\n\r]*null pointer passed as argument 3, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */
38 /* { dg-output "\[^\n\r]*\.c:31:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null" } */