Home | History | Annotate | Download | only in dcl.init
      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.
      8 struct MakeNonPOD { MakeNonPOD(); };
      9 struct NoUserDefault : public MakeNonPOD { };
     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' requires 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 // rdar://8501008
     19 struct s0 {};
     20 struct s1 { static const s0 foo; };
     21 const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' requires a user-provided default constructor}}
     22 
     23 template<typename T>
     24 struct s2 {
     25   static const s0 foo;
     26 };
     27 
     28 template<> const struct s0 s2<int>::foo; // okay
     29