1*67e74705SXin Li // RUN: %clang_cc1 -Wno-uninitialized -fsyntax-only -verify -std=c++11 -Wno-error=static-float-init %s 2*67e74705SXin Li 3*67e74705SXin Li int vs = 0; 4*67e74705SXin Li 5*67e74705SXin Li class C { 6*67e74705SXin Li public: 7*67e74705SXin Li struct NestedC { 8*67e74705SXin Li NestedC(int); 9*67e74705SXin Li }; 10*67e74705SXin Li 11*67e74705SXin Li int i = 0; 12*67e74705SXin Li static int si = 0; // expected-error {{non-const static data member must be initialized out of line}} 13*67e74705SXin Li static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}} 14*67e74705SXin Li static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}} 15*67e74705SXin Li static const int vi = 0; 16*67e74705SXin Li static const volatile int cvi = 0; // expected-error {{static const volatile data member must be initialized out of line}} 17*67e74705SXin Li }; 18*67e74705SXin Li 19*67e74705SXin Li namespace rdar8367341 { 20*67e74705SXin Li float foo(); // expected-note {{here}} 21*67e74705SXin Li 22*67e74705SXin Li struct A { 23*67e74705SXin Li static const float x = 5.0f; // expected-warning {{requires 'constexpr'}} expected-note {{add 'constexpr'}} 24*67e74705SXin Li static const float y = foo(); // expected-warning {{requires 'constexpr'}} expected-note {{add 'constexpr'}} 25*67e74705SXin Li static constexpr float x2 = 5.0f; 26*67e74705SXin Li static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}} 27*67e74705SXin Li }; 28*67e74705SXin Li } 29*67e74705SXin Li 30*67e74705SXin Li 31*67e74705SXin Li namespace Foo { 32*67e74705SXin Li // Regression test -- forward declaration of Foo should not cause error about 33*67e74705SXin Li // nonstatic data member. 34*67e74705SXin Li class Foo; 35*67e74705SXin Li class Foo { 36*67e74705SXin Li int x; 37*67e74705SXin Li int y = x; 38*67e74705SXin Li }; 39*67e74705SXin Li } 40