Debian Codegraph @

gcc/testsuite/g++.dg/ext/attr-pure.C

raw
1 /* PR c++/83871 - wrong code for attribute const and pure on distinct
2 template specializations
3 { dg-do compile }
4 { dg-options "-O -Wall -fdump-tree-optimized" } */
5
6 int __attribute__ ((pure)) fpure_none ();
7 int fpure_none ();
8
9 void func_pure_none_failed ();
10
11 void func_pure_none ()
12 {
13 int i0 = fpure_none ();
14 int i1 = fpure_none ();
15 if (i0 != i1)
16 func_pure_none_failed ();
17
18 // { dg-final { scan-tree-dump-not "func_pure_none_failed" "optimized" } }
19 }
20
21
22 int fnone_pure ();
23 int __attribute__ ((pure)) fnone_pure ();
24
25 void func_none_pure_failed ();
26
27 void func_none_pure ()
28 {
29 int i0 = fnone_pure ();
30 int i1 = fnone_pure ();
31 if (i0 != i1)
32 func_none_pure_failed ();
33
34 // { dg-final { scan-tree-dump-not "func_none_pure_failed" "optimized" } }
35 }
36
37
38 template <class T>
39 int __attribute__ ((pure)) fpure_none (T);
40
41 template <class T>
42 int fpure_none (T);
43
44 void templ_pure_none_failed ();
45
46 void template_pure_none ()
47 {
48 int i0 = fpure_none<int> (0);
49 int i1 = fpure_none<int> (0);
50 if (i0 != i1)
51 templ_pure_none_failed ();
52
53 // { dg-final { scan-tree-dump-not "templ_pure_none_failed" "optimized" } }
54 }
55
56
57 template <class T>
58 int fnone_const (T);
59
60 template <class T>
61 int __attribute__ ((const)) fnone_const (T);
62
63 void templ_none_const_failed ();
64
65 void test_fnone_const ()
66 {
67 int i0 = fnone_const<int> (0);
68 int i1 = fnone_const<int> (0);
69 if (i0 != i1)
70 templ_none_const_failed ();
71
72 // { dg-final { scan-tree-dump-not "templ_none_const_failed" "optimized" } }
73 }