Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / Wfree-nonheap-object.c
blob5f1e3fb28f3e49570a90f7e2f4f4b21d08295795
1 /* Verify that built-in forms of functions can be used interchangeably
2 with their ordinary (library) forms in attribute malloc.
3 { dg-do compile }
4 { dg-options "-Wall" } */
6 char* f (void) __attribute__ ((malloc (__builtin_free)));
8 #if __cplusplus
9 extern "C" {
10 #endif
12 void free (void*);
14 #if __cplusplus
16 #endif
18 char* g (void) __attribute__ ((malloc (free)));
21 void test_nowarm (void)
23 char *p = f ();
24 free (p);
26 p = g ();
27 free (p);
29 p = f ();
30 __builtin_free (p);
32 p = g ();
33 __builtin_free (p);
37 void test_warn (void)
39 char *p = f ();
40 free (p + 1); // { dg-warning "'(free|void free\\(void\\*\\))' called on pointer '(p|<unknown>)' with nonzero offset" }
42 p = g ();
43 free (p + 2); // { dg-warning "'(free|void free\\(void\\*\\))' called on pointer '(p|<unknown>)' with nonzero offset" }
45 p = f ();
46 __builtin_free (p + 3); // { dg-warning "'(__builtin_free|void __builtin_free\\(void\\*\\))' called on pointer '(p|<unknown>)' with nonzero offset" }
48 p = g ();
49 __builtin_free (p + 4); // { dg-warning "'(__builtin_free|void __builtin_free\\(void\\*\\))' called on pointer '(p|<unknown>)' with nonzero offset" }