From: Argyrios Kyrtzidis Date: Tue, 20 Sep 2011 23:49:22 +0000 (+0000) Subject: [ARC] Allow forming 'id*' in an unevaluated context. Fixes rdar://10148540. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b76f373d23cc3b292ecf523349aaaa388eea375;p=clang [ARC] Allow forming 'id*' in an unevaluated context. Fixes rdar://10148540. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140212 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index ee8e52d22e..6b98ed8721 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1038,6 +1038,11 @@ static QualType inferARCLifetimeForPointee(Sema &S, QualType type, } else if (type->isObjCARCImplicitlyUnretainedType()) { implicitLifetime = Qualifiers::OCL_ExplicitNone; + // If we are in an unevaluated context, like sizeof, assume ExplicitNone and + // don't give error. + } else if (S.ExprEvalContexts.back().Context == Sema::Unevaluated) { + implicitLifetime = Qualifiers::OCL_ExplicitNone; + // If that failed, give an error and recover using __autoreleasing. } else { // These types can show up in private ivars in system headers, so diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m index 15ce0e2f6e..054e2bd9b0 100644 --- a/test/SemaObjC/arc.m +++ b/test/SemaObjC/arc.m @@ -646,6 +646,8 @@ void test37(Test37 *c) { for (id y in c) { // expected-error {{collection expression type 'Test37' is a forward declaration}} (void) y; } + + (void)sizeof(id*); // no error. } // rdar://problem/9887979