From 9d145df4c83c54f792ad0fbc7f70ca1a2a77ad9d Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 14 Dec 2015 19:12:54 +0000 Subject: [PATCH] Allow pseudo-destructor calls on forward-declared Objective-C class pointers. rdar://18522255 llvm-svn: 255531 --- clang/lib/Sema/SemaExprCXX.cpp | 7 ++++++- clang/test/SemaObjCXX/pseudo-destructor.mm | 23 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaObjCXX/pseudo-destructor.mm 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 *&);