diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/cxx0x-class.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-class.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx0x-class.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx0x-class.cpp b/clang/test/SemaCXX/cxx0x-class.cpp new file mode 100644 index 0000000..41b0a5c --- /dev/null +++ b/clang/test/SemaCXX/cxx0x-class.cpp @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +int vs = 0; + +class C { +public: + struct NestedC { + NestedC(int); + }; + + int i = 0; + 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 for static data member is not a constant expression}} + static const int vi = 0; + static const volatile int cvi = 0; // expected-error {{static const volatile data member must be initialized out of line}} +}; + +namespace rdar8367341 { + float foo(); // expected-note {{here}} + + struct A { + static const float x = 5.0f; // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}} + static const float y = foo(); // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}} expected-error {{in-class initializer for static data member is not a constant expression}} + static constexpr float x2 = 5.0f; + static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}} + }; +} + + +namespace Foo { + // Regression test -- forward declaration of Foo should not cause error about + // nonstatic data member. + class Foo; + class Foo { + int x; + int y = x; + }; +} |