diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index da34791395be..b6c5d792b6dd 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -5736,9 +5736,14 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, // // This also indicates that we could be parsing a pseudo-destructor-name. // Note that Objective-C class and object types can be pseudo-destructor - // expressions or normal member (ivar or property) access expressions. + // expressions or normal member (ivar or property) access expressions, and + // it's legal for the type to be incomplete if this is a pseudo-destructor + // call. We'll do more incomplete-type checks later in the lookup process, + // so just skip this check for ObjC types. if (BaseType->isObjCObjectOrInterfaceType()) { + ObjectType = ParsedType::make(BaseType); MayBePseudoDestructor = true; + return Base; } else if (!BaseType->isRecordType()) { ObjectType = ParsedType(); MayBePseudoDestructor = true; diff --git a/clang/test/SemaObjCXX/pseudo-destructor.mm b/clang/test/SemaObjCXX/pseudo-destructor.mm new file mode 100644 index 000000000000..06570c16b674 --- /dev/null +++ b/clang/test/SemaObjCXX/pseudo-destructor.mm @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics + +__attribute__((objc_root_class)) +@interface Root +@end + +@class Forward; + +template void destroyPointer(T *t) { + t->~T(); +} + +template void destroyReference(T &t) { + t.~T(); +} + +template void destroyPointer(Root **); +template void destroyReference(Root *&); + +// rdar://18522255 +template void destroyPointer(Forward **); +template void destroyReference(Forward *&);