PR c++/85553
[official-gcc.git] / gcc / testsuite / g++.dg / ext / attr-const.C
blob17cdae6bfbc0726223c3babbbf3e3bb2ef297348
1 /*  PR c++/83871 - wrong code for attribute const and pure on distinct
2     template specializations
3     { dg-do compile }
4     { dg-options "-O1 -Wall -fdump-tree-optimized" } */
6 int __attribute__ ((const)) fconst_none ();
7 int fconst_none ();
9 void func_const_none_failed ();
11 void func_const_none ()
13   int i0 = fconst_none ();
14   int i1 = fconst_none ();
15   if (i0 != i1)
16     func_const_none_failed ();
18   // { dg-final { scan-tree-dump-not "func_const_none_failed" "optimized" } }
22 int fnone_const ();
23 int __attribute__ ((const)) fnone_const ();
25 void func_none_const_failed ();
27 void func_none_const ()
29   int i0 = fnone_const ();
30   int i1 = fnone_const ();
31   if (i0 != i1)
32     func_none_const_failed ();
34   // { dg-final { scan-tree-dump-not "func_none_const_failed" "optimized" } }
37 template <class T>
38 int __attribute__ ((const)) fconst_none (T);
40 template <class T>
41 int fconst_none (T);
43 void templ_const_none_failed ();
45 void template_const_none ()
47   int i0 = fconst_none<int> (0);
48   int i1 = fconst_none<int> (0);
49   if (i0 != i1)
50     templ_const_none_failed ();
52   // { dg-final { scan-tree-dump-not "templ_const_none_failed" "optimized" } }
56 template <class T>
57 int fnone_const (T);
59 template <class T>
60 int __attribute__ ((const)) fnone_const (T);
62 void templ_none_const_failed ();
64 void test_fnone_const ()
66   int i0 = fnone_const<int> (0);
67   int i1 = fnone_const<int> (0);
68   if (i0 != i1)
69     templ_none_const_failed ();
71   // { dg-final { scan-tree-dump-not "templ_none_const_failed" "optimized" } }