diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-04-05 01:13:04 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-04-05 01:13:04 +0000 |
commit | a85cf39786fffd6860a940523be01eb02a4935c0 (patch) | |
tree | 49e6b78abb519f6ddf1db6d7a31f3fbd66ea43c7 /test/CXX | |
parent | 4fd05dc4062580acea72f8b8231fb0ea3ee49032 (diff) |
Improve diagnostics for invalid use of non-static members / this:
* s/nonstatic/non-static/ in the diagnostics, since the latter form outvoted
the former by 28-2 in our diagnostics.
* Fix the "use of member in static member function" diagnostic to correctly
detect this situation inside a block or lambda.
* Produce a more specific "invalid use of non-static member" diagnostic for
the case where a nested class member refers to a member of a
lexically-surrounding class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r-- | test/CXX/class/class.nest/p1.cpp | 4 | ||||
-rw-r--r-- | test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp | 2 | ||||
-rw-r--r-- | test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp | 4 | ||||
-rw-r--r-- | test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp | 2 | ||||
-rw-r--r-- | test/CXX/special/class.free/p1.cpp | 4 | ||||
-rw-r--r-- | test/CXX/special/class.free/p6.cpp | 4 |
6 files changed, 10 insertions, 10 deletions
diff --git a/test/CXX/class/class.nest/p1.cpp b/test/CXX/class/class.nest/p1.cpp index 9eaeff0734..b0341da7c2 100644 --- a/test/CXX/class/class.nest/p1.cpp +++ b/test/CXX/class/class.nest/p1.cpp @@ -5,9 +5,9 @@ class Outer { static int sx; int f(); - // C++0x does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode. + // C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode. class Inner { - static char a[sizeof(x)]; // expected-error {{invalid use of nonstatic data member 'x'}} + static char a[sizeof(x)]; // expected-error {{invalid use of non-static data member 'x'}} static char b[sizeof(sx)]; // okay static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}} }; diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp index 606300b1b2..249c976460 100644 --- a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp @@ -26,7 +26,7 @@ namespace std { } class Poly { virtual ~Poly(); }; const std::type_info& k = typeid(S::m); -const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of nonstatic data member}} +const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}} const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m)); namespace PR11956 { diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp index b9f0414e91..4e57b74f08 100644 --- a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp @@ -2,9 +2,9 @@ struct S { S *p = this; // ok - decltype(this) q; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}} - int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}} int sz = sizeof(this); // ok }; diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp index 9da9fcea1f..4a2a4f3d73 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp @@ -27,7 +27,7 @@ struct ReachingThis { static void static_bar() { (void)[this](){}; // expected-error{{'this' cannot be captured in this context}} - (void)[&](){i = 7; }; // expected-error{{invalid use of nonstatic data member 'i'}} + (void)[&](){i = 7; }; // expected-error{{invalid use of member 'i' in static member function}} } }; } diff --git a/test/CXX/special/class.free/p1.cpp b/test/CXX/special/class.free/p1.cpp index e4fe127f9f..5c0240b5da 100644 --- a/test/CXX/special/class.free/p1.cpp +++ b/test/CXX/special/class.free/p1.cpp @@ -3,9 +3,9 @@ struct A { void *operator new(size_t) { - return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + return this; // expected-error {{invalid use of 'this' outside of a non-static member function}} } void *operator new[](size_t) { - return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + return this; // expected-error {{invalid use of 'this' outside of a non-static member function}} } }; diff --git a/test/CXX/special/class.free/p6.cpp b/test/CXX/special/class.free/p6.cpp index 555d4e9cfa..fc4b2ae1ac 100644 --- a/test/CXX/special/class.free/p6.cpp +++ b/test/CXX/special/class.free/p6.cpp @@ -3,9 +3,9 @@ struct A { void operator delete(void*) { - (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}} } void operator delete[](void*) { - (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}} } }; |