]> granicus.if.org Git - clang/commitdiff
Fix PR8767, improve diagnostic wording when allocating an object of an
authorChandler Carruth <chandlerc@gmail.com>
Fri, 18 Feb 2011 23:59:51 +0000 (23:59 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 18 Feb 2011 23:59:51 +0000 (23:59 +0000)
abstract class type.

Patch by Stephen Hines, with a wording tweak from Doug applied by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125996 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclCXX.cpp
test/CXX/class.derived/class.abstract/p4.cpp
test/CXX/class.derived/class.abstract/p5.cpp
test/SemaCXX/abstract.cpp
test/SemaCXX/exceptions.cpp
test/SemaCXX/virtual-override.cpp

index 9592cbb36ffa8938e473cfe544529693f8fdc0de..d38d14c8565b074f1883cf10bc8127647eb157b5 100644 (file)
@@ -500,7 +500,7 @@ def err_partial_specialization_friend : Error<
 def err_abstract_type_in_decl : Error<
   "%select{return|parameter|variable|field}0 type %1 is an abstract class">;
 def err_allocation_of_abstract_type : Error<
-  "allocation of an object of abstract type %0">;
+  "allocating an object of abstract class type %0">;
 def err_throw_abstract_type : Error<
   "cannot throw an object of abstract type %0">;
 def err_array_of_abstract_type : Error<"array of abstract class type %0">;
@@ -517,7 +517,7 @@ def err_type_defined_in_param_type : Error<
   "%0 can not be defined in a parameter type">;
 
 def note_pure_virtual_function : Note<
-  "pure virtual function %0">;
+  "unimplemented pure virtual method %0 in %1">;
 
 def err_deleted_non_function : Error<
   "only functions can have deleted definitions">;
index 58f656c1454a58ed58877e4a172011086b8515ac..d88d88c37ca1420f0836abb4fac9d91a2522b8c1 100644 (file)
@@ -2535,7 +2535,7 @@ void Sema::DiagnoseAbstractType(const CXXRecordDecl *RD) {
 
       Diag(SO->second.front().Method->getLocation(), 
            diag::note_pure_virtual_function) 
-        << SO->second.front().Method->getDeclName();
+        << SO->second.front().Method->getDeclName() << RD->getDeclName();
     }
   }
 
index ca99bf7f1658e4314e7ea0c9f553049ee2e6cdb3..b04de213874f3b6c8c09b113eaee0fdcc99248e8 100644 (file)
@@ -24,7 +24,7 @@ namespace PR6631 {
 // 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 @@ namespace PartlyPure {
   struct D : B, C { };
 
   void f() {
-    (void) new D; // expected-error{{abstract type}}
+    (void) new D; // expected-error{{abstract class}}
   }
 }
 
index 207519d17e4e775e376b23de8694e70778e29355..cdff9312234458a2d31925d9689ec435d094518d 100644 (file)
@@ -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 B : A {
 };
 
 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}}
 }
index ad079c27c00104b3a187a6d0e9384307f4929936..a6372849509ab2b0818c4520e42eb4bf517a0c50 100644 (file)
@@ -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 @@ class E : D {
 
 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 @@ struct S {
 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 @@ class F {
     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 @@ namespace test1 {
 // 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 @@ namespace test3 {
 
   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 test3 {
 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}}
   };
 }
index 18349d10ef71c15637c0775596ba2175c68a5202..ea3cdd9ef1c479a9d6afefcd40d34bce52266af4 100644 (file)
@@ -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 @@ public:
   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 {
index f3b0d561f9364451b4d3e82aa9d00177ee0b312a..23d86d37426e2eed06e1b98ff13f99ce706c0d63 100644 (file)
@@ -167,7 +167,7 @@ void test2() {
 };
 
 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>