aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-pure.C
blob: 0f259868be18199705e674456a1907f241297892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*  PR c++/83871 - wrong code for attribute const and pure on distinct
    template specializations
    { dg-do compile }
    { dg-options "-O -Wall -fdump-tree-optimized" } */

int __attribute__ ((pure)) fpure_none ();
int fpure_none ();

void func_pure_none_failed ();

void func_pure_none ()
{
  int i0 = fpure_none ();
  int i1 = fpure_none ();
  if (i0 != i1)
    func_pure_none_failed ();

  // { dg-final { scan-tree-dump-not "func_pure_none_failed" "optimized" } }
}


int fnone_pure ();
int __attribute__ ((pure)) fnone_pure ();

void func_none_pure_failed ();

void func_none_pure ()
{
  int i0 = fnone_pure ();
  int i1 = fnone_pure ();
  if (i0 != i1)
    func_none_pure_failed ();

  // { dg-final { scan-tree-dump-not "func_none_pure_failed" "optimized" } }
}


template <class T>
int __attribute__ ((pure)) fpure_none (T);

template <class T>
int fpure_none (T);

void templ_pure_none_failed ();

void template_pure_none ()
{
  int i0 = fpure_none<int> (0);
  int i1 = fpure_none<int> (0);
  if (i0 != i1)
    templ_pure_none_failed ();

  // { dg-final { scan-tree-dump-not "templ_pure_none_failed" "optimized" } }
}


template <class T>
int fnone_const (T);

template <class T>
int __attribute__ ((const)) fnone_const (T);

void templ_none_const_failed ();

void test_fnone_const ()
{
  int i0 = fnone_const<int> (0);
  int i1 = fnone_const<int> (0);
  if (i0 != i1)
    templ_none_const_failed ();

  // { dg-final { scan-tree-dump-not "templ_none_const_failed" "optimized" } }
}