When deleting a value of class type, make sure that type is complete
before looking for conversions to pointer type. Fixes <rdar://problem/8248780>. llvm-svn: 109749
This commit is contained in:
parent
da2955ed74
commit
f65f490ae9
|
@ -2387,6 +2387,8 @@ def err_ambiguous_delete_operand : Error<"ambiguous conversion of delete "
|
|||
"expression of type %0 to a pointer">;
|
||||
def warn_delete_incomplete : Warning<
|
||||
"deleting pointer to incomplete type %0 may cause undefined behaviour">;
|
||||
def err_delete_incomplete_class_type : Warning<
|
||||
"deleting incomplete class type %0; no conversions to pointer type">;
|
||||
def err_no_suitable_delete_member_function_found : Error<
|
||||
"no suitable member %0 in %1">;
|
||||
def note_member_declared_here : Note<
|
||||
|
|
|
@ -1360,6 +1360,10 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
|
|||
QualType Type = Ex->getType();
|
||||
|
||||
if (const RecordType *Record = Type->getAs<RecordType>()) {
|
||||
if (RequireCompleteType(StartLoc, Type,
|
||||
PDiag(diag::err_delete_incomplete_class_type)))
|
||||
return ExprError();
|
||||
|
||||
llvm::SmallVector<CXXConversionDecl*, 4> ObjectPtrConversions;
|
||||
|
||||
CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
|
||||
|
|
|
@ -310,3 +310,14 @@ namespace rdar8018245 {
|
|||
template int *f<X1>(); // expected-note{{in instantiation of}}
|
||||
|
||||
}
|
||||
|
||||
// <rdar://problem/8248780>
|
||||
namespace Instantiate {
|
||||
template<typename T> struct X {
|
||||
operator T*();
|
||||
};
|
||||
|
||||
void f(X<int> &xi) {
|
||||
delete xi;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue