[PATCH] Fix for PR18393 - emit error when abstract type is returned by value
Robert Matusewicz
matekm at gmail.com
Sun Aug 3 07:25:45 PDT 2014
Update diff as tests were not complete - check for note was missing
http://reviews.llvm.org/D4769
Files:
lib/Sema/SemaDecl.cpp
test/SemaCXX/abstract.cpp
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6496,8 +6496,7 @@
// Check that the return type is not an abstract class type.
// For record types, this is done by the AbstractClassUsageDiagnoser once
// the class has been completely parsed.
- if (!DC->isRecord() &&
- SemaRef.RequireNonAbstractType(
+ if (SemaRef.RequireNonAbstractType(
D.getIdentifierLoc(), R->getAs<FunctionType>()->getReturnType(),
diag::err_abstract_type_in_decl, SemaRef.AbstractReturnType))
D.setInvalidType();
Index: test/SemaCXX/abstract.cpp
===================================================================
--- test/SemaCXX/abstract.cpp
+++ test/SemaCXX/abstract.cpp
@@ -307,3 +307,14 @@
RedundantInit() : A(0) {} // expected-warning {{initializer for virtual base class 'pr16659::A' of abstract class 'RedundantInit' will never be used}}
};
}
+
+namespace PR18393 {
+ struct A {
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f' in 'A'}}
+ };
+
+ struct B {
+ A f(); // expected-error {{return type 'PR18393::A' is an abstract class}}
+ };
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4769.12147.patch
Type: text/x-patch
Size: 1250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140803/51ae5197/attachment.bin>
More information about the cfe-commits
mailing list