Diagnose erroneous uses of out-of-line member definitions and scope
specifiers. Specifically:
* Determine when an out-of-line function definition does not match
any declaration within the class or namespace (including coping
with overloaded functions).
* Complain about typedefs and parameters that have scope specifiers.
* Complain about out-of-line declarations that aren't also
definitions.
* Complain about non-static data members being declared out-of-line.
* Allow cv-qualifiers on out-of-line member function definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61058 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index b6032e6..1d91c24 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -12,10 +12,19 @@
A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
class C2 {
- void m();
+ void m(); // expected-note{{member declaration nearly matches}}
+
+ void f(const int& parm); // expected-note{{member declaration nearly matches}}
+ void f(int) const; // expected-note{{member declaration nearly matches}}
+ void f(float);
+
int x;
};
+void C2::m() const { } // expected-error{{out-of-line definition does not match any declaration in 'C2'}}
+
+void C2::f(int) { } // expected-error{{out-of-line definition does not match any declaration in 'C2'}}
+
void C2::m() {
x = 0;
}
@@ -25,7 +34,7 @@
}
void f1() {
- void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
+ void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
}
void f2() {
@@ -73,3 +82,11 @@
// make sure the following doesn't hit any asserts
void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} // expected-error {{expected ')'}} expected-note {{to match this '('}} // expected-error {{variable has incomplete type 'void'}}
+
+typedef void C2::f5(int); // expected-error{{typedef declarator cannot be qualified}}
+
+void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualified}}
+
+int A2::RC::x; // expected-error{{non-static data member defined out-of-line}}
+
+void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}}