* asan.c (pass_sanopt::execute): Handle IFN_UBSAN_OBJECT_SIZE.
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / object-size-5.c
blob3dada101befa42f612e798d290ee200653226a33
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
3 /* { dg-options "-fsanitize=object-size" } */
5 /* Test structures with -fsanitize=object-size. */
7 #define N 20
9 struct S { char *p; int i; };
10 struct T { struct S *s; };
12 __attribute__((noinline, noclone)) void
13 f1 (int i)
15 volatile int j;
16 struct S s;
17 s.p = (char *) __builtin_calloc (N, 1);
18 j = s.p[i];
19 j = *(s.p + i);
20 __builtin_free (s.p);
23 /* { dg-output "load of address \[^\n\r]* with insufficient space for an object of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
24 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
25 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
26 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
27 /* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
28 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
29 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
30 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
32 int
33 main ()
35 f1 (N);
36 f1 (N - 1);
37 return 0;