From 0bdcb8a239baf721a0763f1f01ed3a41cb5b6061 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 29 Jul 2010 16:05:45 +0000 Subject: [PATCH] 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. llvm-svn: 109753 --- clang/lib/Sema/SemaExpr.cpp | 2 ++ clang/test/SemaObjCXX/references.mm | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b2f1a356dfb3..6f971b116d61 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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()); } diff --git a/clang/test/SemaObjCXX/references.mm b/clang/test/SemaObjCXX/references.mm index 70ce8278e8f0..9eceeaf19f5d 100644 --- a/clang/test/SemaObjCXX/references.mm +++ b/clang/test/SemaObjCXX/references.mm @@ -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); +}