brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d925241 Raw
28 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3// FIXME: Very incomplete!4 5// If a program calls for the default initialization of an object of a6// const-qualified type T, T shall be a class type with a7// user-provided default constructor, except if T has no uninitialized fields.8struct MakeNonPOD { MakeNonPOD(); };9struct NoUserDefault : public MakeNonPOD { int field; };10struct HasUserDefault { HasUserDefault(); };11 12void 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 18struct s0 { int field; };19struct s1 { static const s0 foo; };20const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' without a user-provided default constructor}}21 22template<typename T>23struct s2 {24  static const s0 foo;25};26 27template<> const struct s0 s2<int>::foo; // okay28