Debian Codegraph @

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

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