From 62c8b33f4cfaba0c913a7dfaeb4189e0c7df8244 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255531 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 7 ++++++- test/SemaObjCXX/pseudo-destructor.mm | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/SemaObjCXX/pseudo-destructor.mm diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index da34791395..b6c5d792b6 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/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/test/SemaObjCXX/pseudo-destructor.mm b/test/SemaObjCXX/pseudo-destructor.mm new file mode 100644 index 0000000000..06570c16b6 --- /dev/null +++ b/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 *&); -- 2.40.0