Clang doesn't emit error message when return type of declared method is an
abstract type. This error is catched when method is defined but it would be
cool to catch it as soon as possible.
This patch removes check that prevented checking if method return type is
abstract in record context. I also added additional test to prevent regression
in this context.
Br,
Robert
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;
+ };
+
+ struct B {
+ A f(); // expected-error {{return type 'PR18393::A' is an abstract
class}}
+ };
+}
+
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;
+ };
+
+ struct B {
+ A f(); // expected-error {{return type 'PR18393::A' is an abstract class}}
+ };
+}
+
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits