summaryrefslogtreecommitdiff
path: root/clang/test/CXX/class.derived/class.abstract/p4.cpp
blob: b04de213874f3b6c8c09b113eaee0fdcc99248e8 (about) (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
74
75
76
77
78
79
80
// RUN: %clang_cc1 -fsyntax-only -verify %s

namespace PR6631 {
  struct A { 
    virtual void f() = 0;
  };

  struct B : virtual A { };

  struct C : virtual A { 
    virtual void f();
  };

  struct D : public B, public C { 
    virtual void f();
  };

  void f() {
    (void)new D; // okay
  }
}

// Check cases where we have a virtual function that is pure in one
// subobject but not pure in another subobject.
namespace PartlyPure {
  struct A { 
    virtual void f() = 0; // expected-note{{unimplemented pure virtual method}}
  };

  struct B : A {
    virtual void f();
  };

  struct C : virtual A { };

  struct D : B, C { };

  void f() {
    (void) new D; // expected-error{{abstract class}}
  }
}

namespace NonPureAlongOnePath {
  struct A { 
    virtual void f() = 0;
  };

  struct B : virtual A {
    virtual void f();
  };

  struct C : virtual A { };

  struct D : B, C { };

  void f() {
    (void) new D; // okay
  }  
}

namespace NonPureAlongOnePath2 {
  struct Aprime { 
    virtual void f() = 0;
  };

  struct A : Aprime {
  };

  struct B : virtual A {
    virtual void f();
  };

  struct C : virtual A { };

  struct D : B, C { };

  void f() {
    (void) new D; // okay
  }  
}