]> granicus.if.org Git - clang/commitdiff
[ARC] Allow forming 'id*' in an unevaluated context. Fixes rdar://10148540.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 20 Sep 2011 23:49:22 +0000 (23:49 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 20 Sep 2011 23:49:22 +0000 (23:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140212 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/SemaObjC/arc.m

index ee8e52d22e7050bf295dcb3d6124321ef2bf284e..6b98ed872175200624d12837b3148d27646a06cd 100644 (file)
@@ -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
index 15ce0e2f6ebf6abc362d1ca322fd7cf2d99a187a..054e2bd9b04e8987eb4ef6bc3dd17c514f88af14 100644 (file)
@@ -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