summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/overload/addr1.C
blob: 25856a20fc62382eb65d27b15897460e2548d68b (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
// { dg-do run }

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 6 Sep 2003 <nathan@codesourcery.com>
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>

// PR c++/11788 we failed to instantiate a decl, and we lost some side
// effects

static int flag = 0;

template <typename> struct A
{
  A &active ()  { flag++;}
  
  static void foo() {}

  static void bar () {}
  static void bar (int) {}

  int m;
};

void (*baz ()) ()
{
    A<int> a;
    return &a.active ().foo;
}

void (*boz ()) ()
{
    A<int> a;
    return &a.active ().bar;
}

int *buz ()
{
  A<int> a;
  
  return &a.active ().m;
}

int main ()
{
  baz ();
  boz ();
  buz ();
  
  return flag != 3;
}