Debian Codegraph @

clang/test/AST/Interp/constexpr-subobj-initialization.cpp

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
2
3 /// This is like the version in test/SemaCXX/, but some of the
4 /// output types and their location has been adapted.
5 /// Differences:
6 /// 1) The type of the uninitialized base class is printed WITH the namespace,
7 /// i.e. 'baseclass_uninit::DelBase' instead of just 'DelBase'.
8 /// 2) The location is not the base specifier declaration, but the call site
9 /// of the constructor.
10
11
12 namespace baseclass_uninit {
13 struct DelBase {
14 constexpr DelBase() = delete; // expected-note {{'DelBase' has been explicitly marked deleted here}}
15 };
16
17 struct Foo : DelBase {
18 constexpr Foo() {}; // expected-error {{call to deleted constructor of 'DelBase'}}
19 };
20 constexpr Foo f; // expected-error {{must be initialized by a constant expression}} \
21 // expected-note {{constructor of base class 'baseclass_uninit::DelBase' is not called}}
22
23 struct Bar : Foo {
24 constexpr Bar() {};
25 };
26 constexpr Bar bar; // expected-error {{must be initialized by a constant expression}} \
27 // expected-note {{constructor of base class 'baseclass_uninit::DelBase' is not called}}
28
29 struct Base {};
30 struct A : Base {
31 constexpr A() : value() {} // expected-error {{member initializer 'value' does not name a non-static data member or base class}}
32 };
33
34 constexpr A a; // expected-error {{must be initialized by a constant expression}} \
35 // expected-note {{constructor of base class 'baseclass_uninit::Base' is not called}}
36
37
38 struct B : Base {
39 constexpr B() : {} // expected-error {{expected class member or base class name}}
40 };
41
42 constexpr B b; // expected-error {{must be initialized by a constant expression}} \
43 // expected-note {{constructor of base class 'baseclass_uninit::Base' is not called}}
44 } // namespace baseclass_uninit
45
46
47 struct Foo {
48 constexpr Foo(); // expected-note 2{{declared here}}
49 };
50
51 constexpr Foo ff; // expected-error {{must be initialized by a constant expression}} \
52 // expected-note {{undefined constructor 'Foo' cannot be used in a constant expression}}
53
54 struct Bar : protected Foo {
55 int i;
56 constexpr Bar() : i(12) {} // expected-note {{undefined constructor 'Foo' cannot be used in a constant expression}}
57 };
58
59 constexpr Bar bb; // expected-error {{must be initialized by a constant expression}} \
60 // expected-note {{in call to 'Bar()'}}
61
62 template <typename Ty>
63 struct Baz {
64 constexpr Baz(); // expected-note {{declared here}}
65 };
66
67 struct Quux : Baz<Foo>, private Bar {
68 int i;
69 constexpr Quux() : i(12) {} // expected-note {{undefined constructor 'Baz' cannot be used in a constant expression}}
70 };
71
72 constexpr Quux qx; // expected-error {{must be initialized by a constant expression}} \
73 // expected-note {{in call to 'Quux()'}}