Fix PR8767, improve diagnostic wording when allocating an object of an
abstract class type.
Patch by Stephen Hines, with a wording tweak from Doug applied by me.
llvm-svn: 125996
diff --git a/clang/test/CXX/class.derived/class.abstract/p4.cpp b/clang/test/CXX/class.derived/class.abstract/p4.cpp
index ca99bf7..b04de21 100644
--- a/clang/test/CXX/class.derived/class.abstract/p4.cpp
+++ b/clang/test/CXX/class.derived/class.abstract/p4.cpp
@@ -24,7 +24,7 @@
// subobject but not pure in another subobject.
namespace PartlyPure {
struct A {
- virtual void f() = 0; // expected-note{{pure virtual function}}
+ virtual void f() = 0; // expected-note{{unimplemented pure virtual method}}
};
struct B : A {
@@ -36,7 +36,7 @@
struct D : B, C { };
void f() {
- (void) new D; // expected-error{{abstract type}}
+ (void) new D; // expected-error{{abstract class}}
}
}
diff --git a/clang/test/CXX/class.derived/class.abstract/p5.cpp b/clang/test/CXX/class.derived/class.abstract/p5.cpp
index 207519d..cdff931 100644
--- a/clang/test/CXX/class.derived/class.abstract/p5.cpp
+++ b/clang/test/CXX/class.derived/class.abstract/p5.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {
- virtual void f() = 0; // expected-note{{pure virtual function}}
+ virtual void f() = 0; // expected-note{{unimplemented pure virtual method}}
};
struct B : A {
@@ -9,15 +9,15 @@
};
struct C : B {
- virtual void f() = 0; // expected-note 2{{pure virtual function}}
+ virtual void f() = 0; // expected-note 2{{unimplemented pure virtual method}}
};
struct D : C {
};
void test() {
- (void)new A; // expected-error{{object of abstract type}}
+ (void)new A; // expected-error{{abstract class}}
(void)new B;
- (void)new C; // expected-error{{object of abstract type}}
- (void)new D; // expected-error{{object of abstract type}}
+ (void)new C; // expected-error{{abstract class}}
+ (void)new D; // expected-error{{abstract class}}
}
diff --git a/clang/test/SemaCXX/abstract.cpp b/clang/test/SemaCXX/abstract.cpp
index ad079c2..a637284 100644
--- a/clang/test/SemaCXX/abstract.cpp
+++ b/clang/test/SemaCXX/abstract.cpp
@@ -9,7 +9,7 @@
#endif
class C {
- virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f'}}
};
static_assert(__is_abstract(C), "C has a pure virtual function");
@@ -25,7 +25,7 @@
static_assert(!__is_abstract(E), "E inherits from an abstract class but implements f");
-C *d = new C; // expected-error {{allocation of an object of abstract type 'C'}}
+C *d = new C; // expected-error {{allocating an object of type 'C', which is an abstract class}}
C c; // expected-error {{variable type 'C' is an abstract class}}
void t1(C c); // expected-error {{parameter type 'C' is an abstract class}}
@@ -38,8 +38,8 @@
void t3(const C&);
void f() {
- C(); // expected-error {{allocation of an object of abstract type 'C'}}
- t3(C()); // expected-error {{allocation of an object of abstract type 'C'}}
+ C(); // expected-error {{allocating an object of type 'C', which is an abstract class}}
+ t3(C()); // expected-error {{allocating an object of type 'C', which is an abstract class}}
}
C e1[2]; // expected-error {{array of abstract class type 'C'}}
@@ -64,7 +64,7 @@
void u(F c); // expected-error {{parameter type 'F' is an abstract class}}
};
- virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f'}}
};
// Diagnosing in these cases is prohibitively expensive. We still
@@ -193,14 +193,14 @@
// rdar://problem/8302168
namespace test2 {
struct X1 {
- virtual void xfunc(void) = 0; // expected-note {{pure virtual function}}
+ virtual void xfunc(void) = 0; // expected-note {{unimplemented pure virtual method}}
void g(X1 parm7); // expected-error {{parameter type 'test2::X1' is an abstract class}}
void g(X1 parm8[2]); // expected-error {{array of abstract class type 'test2::X1'}}
};
template <int N>
struct X2 {
- virtual void xfunc(void) = 0; // expected-note {{pure virtual function}}
+ virtual void xfunc(void) = 0; // expected-note {{unimplemented pure virtual method}}
void g(X2 parm10); // expected-error {{parameter type 'X2<N>' is an abstract class}}
void g(X2 parm11[2]); // expected-error {{array of abstract class type 'X2<N>'}}
};
@@ -219,11 +219,11 @@
struct C {
static C x; // expected-error {{abstract class}}
- virtual void abstract() = 0; // expected-note {{pure virtual function}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
};
struct D {
- virtual void abstract() = 0; // expected-note {{pure virtual function}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
static D x; // expected-error {{abstract class}}
};
}
@@ -231,21 +231,21 @@
namespace test4 {
template <class T> struct A {
A x; // expected-error {{abstract class}}
- virtual void abstract() = 0; // expected-note {{pure virtual function}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
};
template <class T> struct B {
- virtual void abstract() = 0; // expected-note {{pure virtual function}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
B x; // expected-error {{abstract class}}
};
template <class T> struct C {
static C x; // expected-error {{abstract class}}
- virtual void abstract() = 0; // expected-note {{pure virtual function}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
};
template <class T> struct D {
- virtual void abstract() = 0; // expected-note {{pure virtual function}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
static D x; // expected-error {{abstract class}}
};
}
diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp
index 18349d1..ea3cdd9 100644
--- a/clang/test/SemaCXX/exceptions.cpp
+++ b/clang/test/SemaCXX/exceptions.cpp
@@ -2,7 +2,7 @@
struct A; // expected-note 4 {{forward declaration of 'A'}}
-struct Abstract { virtual void f() = 0; }; // expected-note {{pure virtual function 'f'}}
+struct Abstract { virtual void f() = 0; }; // expected-note {{unimplemented pure virtual method 'f'}}
void trys() {
try {
@@ -105,7 +105,7 @@
void bar () {
throw *this; // expected-error{{cannot throw an object of abstract type 'foo'}}
}
- virtual void test () = 0; // expected-note{{pure virtual function 'test'}}
+ virtual void test () = 0; // expected-note{{unimplemented pure virtual method 'test'}}
};
namespace PR6831 {
diff --git a/clang/test/SemaCXX/virtual-override.cpp b/clang/test/SemaCXX/virtual-override.cpp
index f3b0d56..23d86d3 100644
--- a/clang/test/SemaCXX/virtual-override.cpp
+++ b/clang/test/SemaCXX/virtual-override.cpp
@@ -167,7 +167,7 @@
};
struct Foo3 {
- virtual void f(int) = 0; // expected-note{{pure virtual function}}
+ virtual void f(int) = 0; // expected-note{{unimplemented pure virtual method}}
};
template<typename T>