summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/class.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-09-10 23:21:22 +0000
committerJohn McCall <rjmccall@apple.com>2010-09-10 23:21:22 +0000
commitdb76892e72e458030804b9d6d9e2eea16d52f229 (patch)
tree2db0059dbf234b610cf64617ed4daee2299eb444 /clang/test/SemaCXX/class.cpp
parent72497e5d90807a40eb4d8d311e9e0c0e011c6e4c (diff)
downloadbcm5719-llvm-db76892e72e458030804b9d6d9e2eea16d52f229.tar.gz
bcm5719-llvm-db76892e72e458030804b9d6d9e2eea16d52f229.zip
Support in-class initialization of static const floating-point data members.
llvm-svn: 113663
Diffstat (limited to 'clang/test/SemaCXX/class.cpp')
-rw-r--r--clang/test/SemaCXX/class.cpp23
1 files changed, 17 insertions, 6 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}}
+ };
+}
OpenPOWER on IntegriCloud