Debian Codegraph @

clang/test/CXX/dcl.decl/dcl.init/p6.cpp

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 // FIXME: Very incomplete!
4
5 // If a program calls for the default initialization of an object of a
6 // const-qualified type T, T shall be a class type with a
7 // user-provided default constructor, except if T has no uninitialized fields.
8 struct MakeNonPOD { MakeNonPOD(); };
9 struct NoUserDefault : public MakeNonPOD { int field; };
10 struct HasUserDefault { HasUserDefault(); };
11
12 void test_const_default_init() {
13 const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' without a user-provided default constructor}}
14 const HasUserDefault x2;
15 const int x3; // expected-error{{default initialization of an object of const type 'const int'}}
16 }
17
18 struct s0 { int field; };
19 struct s1 { static const s0 foo; };
20 const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' without a user-provided default constructor}}
21
22 template<typename T>
23 struct s2 {
24 static const s0 foo;
25 };
26
27 template<> const struct s0 s2<int>::foo; // okay