* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / object-size-11.c
blob866c7ed4086e5b93e2c4e63ed1333ab369cc4c81
1 /* PR sanitizer/81094 */
2 /* { dg-do run } */
3 /* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
4 /* { dg-options "-fsanitize=object-size" } */
6 #define N 20
8 struct S { int i; };
10 __attribute__((noinline, noclone)) void
11 f0 (struct S s)
13 asm volatile ("" : : "r" (s.i) : "memory");
16 __attribute__((noinline, noclone)) void
17 f1 (int i)
19 char *orig;
20 struct S *p;
21 orig = (char *) __builtin_calloc (N, sizeof (struct S));
22 p = (struct S *) orig;
23 f0 (*(p + i));
24 f0 (p[i]);
25 p++;
26 f0 (p[i - 1]);
27 f0 (*(p + i - 1));
28 __builtin_free (orig);
31 /* { dg-output "load of address \[^\n\r]* with insufficient space for an object of type 'struct S'\[^\n\r]*(\n|\r\n|\r)" } */
32 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
33 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
34 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
35 /* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'struct S'\[^\n\r]*(\n|\r\n|\r)" } */
36 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
37 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
38 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
39 /* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'struct S'\[^\n\r]*(\n|\r\n|\r)" } */
40 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
41 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
42 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
43 /* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'struct S'\[^\n\r]*(\n|\r\n|\r)" } */
44 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
45 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
46 /* { dg-output "\[^\n\r]*\\^" } */
48 int
49 main ()
51 f1 (N);
52 return 0;