r255531 - Allow pseudo-destructor calls on forward-declared Objective-C class pointers.
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 14 11:12:54 PST 2015
Author: rjmccall
Date: Mon Dec 14 13:12:54 2015
New Revision: 255531
URL: http://llvm.org/viewvc/llvm-project?rev=255531&view=rev
Log:
Allow pseudo-destructor calls on forward-declared Objective-C class pointers.
rdar://18522255
Added:
cfe/trunk/test/SemaObjCXX/pseudo-destructor.mm
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=255531&r1=255530&r2=255531&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Dec 14 13:12:54 2015
@@ -5736,9 +5736,14 @@ ExprResult Sema::ActOnStartCXXMemberRefe
//
// 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;
Added: cfe/trunk/test/SemaObjCXX/pseudo-destructor.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/pseudo-destructor.mm?rev=255531&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/pseudo-destructor.mm (added)
+++ cfe/trunk/test/SemaObjCXX/pseudo-destructor.mm Mon Dec 14 13:12:54 2015
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+__attribute__((objc_root_class))
+ at interface Root
+ at end
+
+ at class Forward;
+
+template <class T> void destroyPointer(T *t) {
+ t->~T();
+}
+
+template <class T> void destroyReference(T &t) {
+ t.~T();
+}
+
+template void destroyPointer<Root*>(Root **);
+template void destroyReference<Root*>(Root *&);
+
+// rdar://18522255
+template void destroyPointer<Forward*>(Forward **);
+template void destroyReference<Forward*>(Forward *&);
More information about the cfe-commits
mailing list