diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/class.cpp | 23 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-static-var.cpp | 4 |
2 files changed, 19 insertions, 8 deletions
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp index e51d0fdff97..ad0792c9c42 100644 --- a/clang/test/SemaCXX/class.cpp +++ b/clang/test/SemaCXX/class.cpp @@ -12,16 +12,18 @@ public: } class NestedC { + public: + NestedC(int); void m() { sx = 0; - x = 0; // expected-error {{error: invalid use of nonstatic data member 'x'}} + x = 0; // expected-error {{invalid use of nonstatic data member 'x'}} } }; int b : 1, w : 2; int : 1, : 2; typedef int E : 1; // expected-error {{typedef member 'E' cannot be a bit-field}} - static int sb : 1; // expected-error {{error: static member 'sb' cannot be a bit-field}} + static int sb : 1; // expected-error {{static member 'sb' cannot be a bit-field}} static int vs; typedef int func(); @@ -32,10 +34,10 @@ public: enum E1 { en1, en2 }; - int i = 0; // expected-error {{error: 'i' can only be initialized if it is a static const integral data member}} - static int si = 0; // expected-error {{error: 'si' can only be initialized if it is a static const integral data member}} - static const NestedC ci = 0; // expected-error {{error: 'ci' can only be initialized if it is a static const integral data member}} - static const int nci = vs; // expected-error {{in-class initializer is not an integral constant expression}} + int i = 0; // expected-error {{fields can only be initialized in constructors}} + static int si = 0; // expected-error {{non-const static data member must be initialized out of line}} + static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}} + static const int nci = vs; // expected-error {{in-class initializer is not a constant expression}} static const int vi = 0; static const E evi = 0; @@ -165,3 +167,12 @@ namespace rdar8066414 { C() {} } // expected-error{{expected ';' after class}} } + +namespace rdar8367341 { + float foo(); + + struct A { + static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a C++0x extension}} + static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a C++0x extension}} expected-error {{in-class initializer is not a constant expression}} + }; +} diff --git a/clang/test/SemaTemplate/instantiate-static-var.cpp b/clang/test/SemaTemplate/instantiate-static-var.cpp index e90ac5223d9..cd25ccb3d31 100644 --- a/clang/test/SemaTemplate/instantiate-static-var.cpp +++ b/clang/test/SemaTemplate/instantiate-static-var.cpp @@ -2,7 +2,7 @@ template<typename T, T Divisor> class X { public: - static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}} + static const T value = 10 / Divisor; // expected-error{{in-class initializer is not a constant expression}} }; int array1[X<int, 2>::value == 5? 1 : -1]; @@ -11,7 +11,7 @@ X<int, 0> xi0; // expected-note{{in instantiation of template class 'X<int, 0>' template<typename T> class Y { - static const T value = 0; // expected-error{{'value' can only be initialized if it is a static const integral data member}} + static const T value = 0; // expected-warning{{in-class initializer for static data member of type 'float const' is a C++0x extension}} }; Y<float> fy; // expected-note{{in instantiation of template class 'Y<float>' requested here}} |