[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / ext / attr-malloc-2.C
blob600d430468c508992dd1ef4a56cce4a3a5a2ef56
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" }
8 void* __attribute__ ((malloc))
9 fmalloc_none (unsigned);
11 void*
12 fmalloc_none (unsigned);
14 static char a[8];
16 void fmalloc_none_failed ();
18 void test_fmalloc_none (void)
20   void *p = fmalloc_none (1);
21   if (!p)
22     return;
24   if (p == a)                     // must be false
25     fmalloc_none_failed ();       // should be eliminated
27   // Verify that the call to fmalloc_none() is eliminated.
28   // { dg-final { scan-tree-dump-not "fmalloc_none_failed" "optimized" } }
31 void* fnone_malloc (unsigned);
33 void* __attribute__ ((malloc))
34 fnone_malloc (unsigned);
36 void fnone_malloc_failed ();
38 void test_fnone_malloc (void)
40   void *p = fnone_malloc (1);
41   if (!p)
42     return;
44   if (p == a)                     // must be false
45     fnone_malloc_failed ();       // should be eliminated
47   // Verify that the call to fnone_malloc() is eliminated.
48   // { dg-final { scan-tree-dump-not "fnone_malloc_failed" "optimized" } }