Add missing check for creating an instance of an abstract class through an

implicit conversion sequence.

llvm-svn: 186769
This commit is contained in:
Richard Smith 2013-07-20 19:41:36 +00:00
parent 070a5d6750
commit 72d74057ea
2 changed files with 12 additions and 1 deletions

View File

@ -2415,6 +2415,10 @@ static ExprResult BuildCXXCastArgument(Sema &S,
CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(Method);
SmallVector<Expr*, 8> ConstructorArgs;
if (S.RequireNonAbstractType(CastLoc, Ty,
diag::err_allocation_of_abstract_type))
return ExprError();
if (S.CompleteConstructorCall(Constructor, From, CastLoc, ConstructorArgs))
return ExprError();
@ -2500,7 +2504,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
BeforeToType = Ctor->getParamDecl(0)->getType().getNonReferenceType();
}
}
// Watch out for elipsis conversion.
// Watch out for ellipsis conversion.
if (!ICS.UserDefined.EllipsisConversion) {
ExprResult Res =
PerformImplicitConversion(From, BeforeToType,

View File

@ -250,6 +250,13 @@ namespace test4 {
};
}
namespace test5 {
struct A { A(int); virtual ~A() = 0; }; // expected-note {{pure virtual method}}
const A &a = 0; // expected-error {{abstract class}}
void f(const A &a = 0); // expected-error {{abstract class}}
void g() { f(0); } // expected-error {{abstract class}}
}
// PR9247: Crash on invalid in clang::Sema::ActOnFinishCXXMemberSpecification
namespace pr9247 {
struct A {