blob: 514fd0c9b62038ec8a9d82d43a3ba165d79a9453 [file] [log] [blame]
Douglas Gregor9db7dbb2010-01-31 09:12:51 +00001// 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.
Douglas Gregor516a6bc2010-03-08 02:45:10 +00008struct MakeNonPOD { MakeNonPOD(); };
9struct NoUserDefault : public MakeNonPOD { };
Douglas Gregor9db7dbb2010-01-31 09:12:51 +000010struct HasUserDefault { HasUserDefault(); };
11
12void test_const_default_init() {
Chris Lattner0c42bb62010-09-05 00:17:29 +000013 const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' requires a user-provided default constructor}}
Douglas Gregor9db7dbb2010-01-31 09:12:51 +000014 const HasUserDefault x2;
Chris Lattner58f9e132010-09-05 00:04:01 +000015 const int x3; // expected-error{{default initialization of an object of const type 'const int'}}
Douglas Gregor9db7dbb2010-01-31 09:12:51 +000016}
Douglas Gregor4337dc72011-05-21 17:52:48 +000017
18// rdar://8501008
19struct s0 {};
20struct s1 { static const s0 foo; };
21const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' requires a user-provided default constructor}}
22
23template<typename T>
24struct s2 {
25 static const s0 foo;
26};
27
28template<> const struct s0 s2<int>::foo; // okay