diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 4923480737ee..35152617336a 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -2445,16 +2445,24 @@ QualType TreeTransform::TransformPointerType(TypeLocBuilder &TLB, return QualType(); QualType Result = TL.getType(); - if (PointeeType->isObjCInterfaceType()) { + if (PointeeType->isObjCInterfaceType() || + PointeeType->isSpecificBuiltinType(BuiltinType::ObjCId)) { // A dependent pointer type 'T *' has is being transformed such // that an Objective-C class type is being replaced for 'T'. The // resulting pointer type is an ObjCObjectPointerType, not a // PointerType. - const ObjCInterfaceType *IFace = PointeeType->getAs(); + ObjCProtocolDecl **Protocols = 0; + unsigned NumProtocols = 0; + + if (const ObjCInterfaceType *IFace + = PointeeType->getAs()) { + Protocols = const_cast(IFace->qual_begin()); + NumProtocols = IFace->getNumProtocols(); + } + Result = SemaRef.Context.getObjCObjectPointerType(PointeeType, - const_cast( - IFace->qual_begin()), - IFace->getNumProtocols()); + Protocols, + NumProtocols); ObjCObjectPointerTypeLoc NewT = TLB.push(Result); NewT.setStarLoc(TL.getSigilLoc()); diff --git a/clang/test/SemaObjCXX/deduction.mm b/clang/test/SemaObjCXX/deduction.mm index 2c153aa9a665..0d2fc06dc35a 100644 --- a/clang/test/SemaObjCXX/deduction.mm +++ b/clang/test/SemaObjCXX/deduction.mm @@ -21,4 +21,8 @@ namespace test0 { void test(NSString *S) { RetainPtr ptr(S); } + + void test(id S) { + RetainPtr ptr(S); + } }