Debian Codegraph @

gcc/testsuite/g++.dg/inherit/pr97268.C

raw
1 // { dg-do compile { target c++11 } }
2 // { dg-additional-options -Wall }
3 // PR 97268, ICE due to broken inherited-from-virtual base-ctor
4 class Handle {
5 public:
6 explicit Handle(char const *const &) { }
7 ~Handle() {}
8 Handle(const Handle &) = delete;
9 Handle &operator=(const Handle &) = delete;
10
11 protected:
12 int lasterr = 0;
13
14 };
15
16 struct ObjectBase {
17 ~ObjectBase() {}
18
19 protected:
20 explicit ObjectBase(const char *lc_, int ln_, Handle &h, unsigned)
21 : handle(h) { }
22
23 protected:
24
25 Handle &handle;
26 };
27
28 template <bool CACHED>
29 struct Object : virtual public ObjectBase {
30 explicit Object(const char *lc_, int ln_, Handle &env);
31
32 protected:
33 using ObjectBase::ObjectBase;
34
35 };
36
37 class BetterObjectBase : virtual public ObjectBase {
38 protected:
39 BetterObjectBase(const char *lc_, int ln_, Handle &env)
40 : ObjectBase("", 0, env, 0) {}
41
42 };
43
44 template <bool CACHED>
45 class BetterObject : public Object<CACHED>, public BetterObjectBase {
46 public:
47 BetterObject(Handle &env)
48 : ObjectBase("", 0, env, 0)
49 , Object<CACHED>("", 0, env, 0)
50 , BetterObjectBase("", 0, env) {} // { dg-error "use of deleted function" }
51
52 };
53
54 int main() {
55 Handle h("handle");
56
57 BetterObject<true> B(h);
58
59 return 0;
60 }