When taking the address of a value of Objective-C object type (e.g.,
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
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index b2f1a35..6f971b1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6313,6 +6313,8 @@
}
// 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());
}
diff --git a/test/SemaObjCXX/references.mm b/test/SemaObjCXX/references.mm
index 70ce827..9eceeaf 100644
--- a/test/SemaObjCXX/references.mm
+++ b/test/SemaObjCXX/references.mm
@@ -24,3 +24,10 @@
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);
+}