]> granicus.if.org Git - clang/commitdiff
When taking the address of a value of Objective-C object type (e.g.,
authorDouglas Gregor <dgregor@apple.com>
Thu, 29 Jul 2010 16:05:45 +0000 (16:05 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 29 Jul 2010 16:05:45 +0000 (16:05 +0000)
one because we're referencing a variable of type NSString &), the
resulting type is an ObjCObjectPointerType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109753 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaObjCXX/references.mm

index b2f1a356dfb3b791a57394a0a9f8f287ba39cd81..6f971b116d61377794b2baae4717cc768481bee6 100644 (file)
@@ -6313,6 +6313,8 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
   }
 
   // If the operand has type "type", the result has type "pointer to type".
+  if (op->getType()->isObjCObjectType())
+    return Context.getObjCObjectPointerType(op->getType());
   return Context.getPointerType(op->getType());
 }
 
index 70ce8278e8f0c6caad0177eccac2c0dda0adee45..9eceeaf19f5dea672ecbe960e127572700f50733 100644 (file)
@@ -24,3 +24,10 @@ int f2(A *a) {
   return f0(a.p1);     // expected-error {{property 'p1' not found on object of type 'A *'}}
 }
 
+// PR7740
+@class NSString;
+
+void f3(id);
+void f4(NSString &tmpstr) {
+  f3(&tmpstr);
+}