1 // Bug c++/83503 - bogus -Wattributes for const and pure on function template
3 // Test to verify that an explicit template specifialization does not
4 // "inherit" attribute malloc from a primary template declared with one.
6 // { dg-options "-O -Wall -fdump-tree-optimized" }
9 void* __attribute__ ((malloc))
14 fmalloc<int>(unsigned); // { dg-warning "may be missing attributes" }
18 void fmalloc_void_malloc ();
19 void fmalloc_int_not_malloc ();
21 void test_fmalloc_primary (void)
23 void *p = fmalloc<void>(1);
27 if (p == a) // must be false
28 fmalloc_void_malloc (); // should be eliminated
30 // Verify that the call to fmalloc_void_malloc() is eliminated.
31 // { dg-final { scan-tree-dump-not "fmalloc_void_malloc" "optimized" } }
35 void test_fmalloc_spec_none (void)
37 void *p = fmalloc<int>(1);
41 if (p == a) // can be true
42 fmalloc_int_not_malloc (); // must not be eliminated
44 // Verify that the call to fmalloc_int_not_malloc() is retained.
45 // { dg-final { scan-tree-dump-times "fmalloc_int_not_malloc" 1 "optimized" } }
50 fmalloc<long>(unsigned); // { dg-warning "may be missing attributes" }
53 void* __attribute__ ((malloc))
54 fmalloc<long>(unsigned);
56 void fmalloc_long_malloc ();
58 void test_fmalloc_spec_malloc (void)
60 void *p = fmalloc<long>(1);
64 if (p == a) // can be true
65 fmalloc_long_malloc (); // must not be eliminated
67 // Verify that the call to fmalloc_long_malloc() is eliminated.
68 // { dg-final { scan-tree-dump-not "fmalloc_long_malloc" "optimized" } }