131
|
1 // Bug c++/84617 - new test cases g++.dg/ext/attr-const.C and
|
|
2 // g++.dg/ext/attr-pure.C fail
|
|
3 // { dg-do compile }
|
|
4 // { dg-options "-O -Wall -fdump-tree-optimized" }
|
|
5
|
|
6 static char a[8];
|
|
7
|
|
8 void* __attribute__ ((malloc))
|
|
9 func_malloc_none (unsigned);
|
|
10
|
|
11 void*
|
|
12 func_alloc_none (unsigned); // redeclare with no attribute
|
|
13
|
|
14 void func_malloc_none_failed ();
|
|
15
|
|
16 void test_func_malloc_none (void)
|
|
17 {
|
|
18 void *p = func_malloc_none (1);
|
|
19 if (!p)
|
|
20 return;
|
|
21
|
|
22 if (p == a) // must be false
|
|
23 func_malloc_none_failed (); // should be eliminated
|
|
24
|
|
25 // Verify that the call to func_malloc_none_failed() is eliminated.
|
|
26 // { dg-final { scan-tree-dump-not "func_malloc_none_failed" "optimized" } }
|
|
27 }
|
|
28
|
|
29
|
|
30 void*
|
|
31 func_none_malloc (unsigned);
|
|
32
|
|
33 void* __attribute__ ((malloc))
|
|
34 func_none_malloc (unsigned); // redeclare with an attribute
|
|
35
|
|
36 void func_none_malloc_failed ();
|
|
37
|
|
38 void test_func_none_malloc (void)
|
|
39 {
|
|
40 void *p = func_none_malloc (1);
|
|
41 if (!p)
|
|
42 return;
|
|
43
|
|
44 if (p == a) // must be false
|
|
45 func_none_malloc_failed (); // should be eliminated
|
|
46
|
|
47 // Verify that the call to func_none_malloc_failed() is eliminated.
|
|
48 // { dg-final { scan-tree-dump-not "func_none_malloc_failed" "optimized" } }
|
|
49 }
|
|
50
|
|
51
|
|
52 template <class>
|
|
53 void* __attribute__ ((malloc))
|
|
54 templ_malloc_none (unsigned);
|
|
55
|
|
56 template <class>
|
|
57 void*
|
|
58 templ_malloc_none (unsigned); // redeclare with no attribute
|
|
59
|
|
60 void templ_malloc_none_failed ();
|
|
61
|
|
62 void test_templ_malloc_none (void)
|
|
63 {
|
|
64 void *p = templ_malloc_none<void>(1);
|
|
65 if (!p)
|
|
66 return;
|
|
67
|
|
68 if (p == a) // must be false
|
|
69 templ_malloc_none_failed (); // should be eliminated
|
|
70
|
|
71 // Verify that the call to templ_malloc_none_failed() is eliminated.
|
|
72 // { dg-final { scan-tree-dump-not "templ_malloc_none_failed" "optimized" } }
|
|
73 }
|
|
74
|
|
75 template <class>
|
|
76 void*
|
|
77 templ_none_malloc (unsigned);
|
|
78
|
|
79 template <class>
|
|
80 void* __attribute__ ((malloc))
|
|
81 templ_none_malloc (unsigned); // redeclared with an attribute
|
|
82
|
|
83 void templ_none_malloc_failed ();
|
|
84
|
|
85 void test_templ_none_malloc (void)
|
|
86 {
|
|
87 void *p = templ_none_malloc<void>(1);
|
|
88 if (!p)
|
|
89 return;
|
|
90
|
|
91 if (p == a) // must be false
|
|
92 templ_none_malloc_failed (); // should be eliminated
|
|
93
|
|
94 // Verify that the call to templ_none_malloc_failed() is eliminated.
|
|
95 // { dg-final { scan-tree-dump-not "templ_none_malloc_failed" "optimized" } }
|
|
96 }
|