aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/override1.C
blob: e05693fc59088776c3dd6ba8dc353de3a78922b2 (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
// { dg-do compile { target c++11 } }
struct B
{
  virtual void f() final {}
  virtual void g() {}
  virtual void x() const {}
};

struct B2
{
  virtual void h() {}
};

struct D : B
{
  virtual void g() override final {} // { dg-error "overriding" }
};

template <class T> struct D2 : T
{
  void h() override {} // { dg-error "marked override, but does not override" }
};

template <class T> struct D3 : T
{
  void h() override {}
};

struct D4 : D
{
  void g() {} // { dg-error "virtual function" }
};

struct B3
{
  virtual void f() final final {} // { dg-error "duplicate virt-specifier" }
};

struct B4
{
  void f() final {} // { dg-error "marked final, but is not virtual" }
};

struct D5 : B
{
  void ff() override {} // { dg-error "marked override, but does not override" }
  virtual void fff() override {} // { dg-error "marked override, but does not override" }
  virtual void x() override {} // { dg-error "marked override, but does not override" }
  void g() override;
};

void D5::g() override {} // { dg-error "not allowed outside a class definition" }
void g() override {} // { dg-error "not allowed outside a class definition" }

int main()
{
  D2<B> d;
  D2<B2> d2;
  D3<B2> d3;
}