Debian Codegraph @

clang/test/SemaCXX/constexpr-subobj-initialization.cpp

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 namespace baseclass_uninit {
4 struct DelBase {
5 constexpr DelBase() = delete; // expected-note {{'DelBase' has been explicitly marked deleted here}}
6 };
7
8 struct Foo : DelBase { // expected-note 2{{constructor of base class 'DelBase' is not called}}
9 constexpr Foo() {}; // expected-error {{call to deleted constructor of 'DelBase'}}
10 };
11 constexpr Foo f; // expected-error {{must be initialized by a constant expression}}
12 struct Bar : Foo {
13 constexpr Bar() {};
14 };
15 constexpr Bar bar; // expected-error {{must be initialized by a constant expression}}
16
17 struct Base {};
18 struct A : Base { // expected-note {{constructor of base class 'Base' is not called}}
19 constexpr A() : value() {} // expected-error {{member initializer 'value' does not name a non-static data member or base class}}
20 };
21
22 constexpr A a; // expected-error {{must be initialized by a constant expression}}
23
24 struct B : Base { // expected-note {{constructor of base class 'Base' is not called}}
25 constexpr B() : {} // expected-error {{expected class member or base class name}}
26 };
27
28 constexpr B b; // expected-error {{must be initialized by a constant expression}}
29 } // namespace baseclass_uninit
30
31
32 struct Foo {
33 constexpr Foo(); // expected-note 2{{declared here}}
34 };
35
36 constexpr Foo ff; // expected-error {{must be initialized by a constant expression}} \
37 // expected-note {{undefined constructor 'Foo' cannot be used in a constant expression}}
38
39 struct Bar : protected Foo {
40 int i;
41 constexpr Bar() : i(12) {} // expected-note {{undefined constructor 'Foo' cannot be used in a constant expression}}
42 };
43
44 constexpr Bar bb; // expected-error {{must be initialized by a constant expression}} \
45 // expected-note {{in call to 'Bar()'}}
46
47 template <typename Ty>
48 struct Baz {
49 constexpr Baz(); // expected-note {{declared here}}
50 };
51
52 struct Quux : Baz<Foo>, private Bar {
53 int i;
54 constexpr Quux() : i(12) {} // expected-note {{undefined constructor 'Baz' cannot be used in a constant expression}}
55 };
56
57 constexpr Quux qx; // expected-error {{must be initialized by a constant expression}} \
58 // expected-note {{in call to 'Quux()'}}