summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/template3.C
blob: 09c8571871a38915d2bda975fb05cff45db2b01f (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  }
// GROUPS passed templates
extern "C" int printf (const char *, ...);
extern "C" void exit (int);

int count = 0;

void
die (int x)
{
  if (x != ++count)
    {
      printf ("FAIL\n");
      exit (1);
    }
}

class A {
  public:
    void   f() const { die (-1); }
};


template <class Item>
class B : public A {
  public:
  void f() const;
};

template <class Item>
inline void B<Item>::f() const { die (1); }

template <class Item>
class C : public A {
  public:
    void f() const { die (2); }
};


int main()
{
    B<int> b;
    C<int> c;

    b.f(); //- bugged, (A::f() called instead of B::f())
    c.f(); //- works fine (C::f() called)

    printf ("PASS\n");
    return 0;
}