comparison gcc/testsuite/g++.dg/ext/attr-malloc-2.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 // Bug c++/83503 - bogus -Wattributes for const and pure on function template
2 // specialization
3 // Test to verify that attribute malloc on multiple declarations of
4 // the same ordinary function are merged.
5 // { dg-do compile }
6 // { dg-options "-O -Wall -fdump-tree-optimized" }
7
8 void* __attribute__ ((malloc))
9 fmalloc_none (unsigned);
10
11 void*
12 fmalloc_none (unsigned);
13
14 static char a[8];
15
16 void fmalloc_none_failed ();
17
18 void test_fmalloc_none (void)
19 {
20 void *p = fmalloc_none (1);
21 if (!p)
22 return;
23
24 if (p == a) // must be false
25 fmalloc_none_failed (); // should be eliminated
26
27 // Verify that the call to fmalloc_none() is eliminated.
28 // { dg-final { scan-tree-dump-not "fmalloc_none_failed" "optimized" } }
29 }
30
31 void* fnone_malloc (unsigned);
32
33 void* __attribute__ ((malloc))
34 fnone_malloc (unsigned);
35
36 void fnone_malloc_failed ();
37
38 void test_fnone_malloc (void)
39 {
40 void *p = fnone_malloc (1);
41 if (!p)
42 return;
43
44 if (p == a) // must be false
45 fnone_malloc_failed (); // should be eliminated
46
47 // Verify that the call to fnone_malloc() is eliminated.
48 // { dg-final { scan-tree-dump-not "fnone_malloc_failed" "optimized" } }
49 }