Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / constexpr-subobj-initialization.cpp
blobcd096a92709378733be2f65f006892d6c6185f53
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 namespace baseclass_uninit {
4 struct DelBase {
5 constexpr DelBase() = delete; // expected-note {{'DelBase' has been explicitly marked deleted here}}
6 };
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'}}
11 constexpr Foo f; // expected-error {{must be initialized by a constant expression}}
12 struct Bar : Foo {
13 constexpr Bar() {};
15 constexpr Bar bar; // expected-error {{must be initialized by a constant expression}}
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}}
22 constexpr A a; // expected-error {{must be initialized by a constant expression}}
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}}
28 constexpr B b; // expected-error {{must be initialized by a constant expression}}
29 } // namespace baseclass_uninit
32 struct Foo {
33 constexpr Foo(); // expected-note 2{{declared here}}
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}}
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}}
44 constexpr Bar bb; // expected-error {{must be initialized by a constant expression}} \
45 // expected-note {{in call to 'Bar()'}}
47 template <typename Ty>
48 struct Baz {
49 constexpr Baz(); // expected-note {{declared here}}
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}}
57 constexpr Quux qx; // expected-error {{must be initialized by a constant expression}} \
58 // expected-note {{in call to 'Quux()'}}