]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/Wnonnull.c
1 /* PR tree-optimization/83369 - Missing diagnostics during inlining
3 { dg-options "-O2 -Wall" } */
8 /* OSX headers do not mark up the nonnull elements yet. */
10 extern size_t strlen (const char *__s
)
11 __attribute ((pure
)) __attribute ((nonnull (1)));
12 extern void *memcpy (void *__restrict __dest
, const void *__restrict __src
,
13 size_t __n
) __attribute ((nonnull (1, 2)));
24 __attribute ((nonnull (1, 2)))
26 my_strcpy (char *restrict dst
, const char *restrict src
, size_t size
)
28 size_t len
= strlen (src
); /* { dg-warning "argument 1 null where non-null expected" } */
30 memcpy (dst
, src
, len
+ 1); /* { dg-warning "argument 2 null where non-null expected" } */
33 memcpy (dst
, src
, size
- 1); /* { dg-warning "argument 2 null where non-null expected" } */
39 void test (struct Test
* test
)
42 my_strcpy (buf
, test
->s1
, sizeof buf
);
44 my_strcpy (buf
, test
->s2
, sizeof buf
);
46 my_strcpy (buf
, test
->s2
, sizeof buf
);
49 /* Verify that the inlining context is printed for -Wnonnull:
50 { dg-message "function .my_strcpy..*inlined from .test." "" { target *-*-* } 0 } */