diff options
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 6 | ||||
-rw-r--r-- | test/CodeGenObjCXX/copy.mm | 15 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index d2ad5dc887..e3b93a3f45 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -954,9 +954,13 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, if (Arg->getType().isRestrictQualified()) AI->addAttr(llvm::Attribute::NoAlias); + // Ensure the argument is the correct type. + if (V->getType() != ArgI.getCoerceToType()) + V = Builder.CreateBitCast(V, ArgI.getCoerceToType()); + if (isPromoted) V = emitArgumentDemotion(*this, Arg, V); - + EmitParmDecl(*Arg, V, ArgNo); break; } diff --git a/test/CodeGenObjCXX/copy.mm b/test/CodeGenObjCXX/copy.mm index 133910f25d..e97ca79d3b 100644 --- a/test/CodeGenObjCXX/copy.mm +++ b/test/CodeGenObjCXX/copy.mm @@ -24,3 +24,18 @@ namespace test0 { } } + +// rdar://9780211 +@protocol bork +@end + +namespace test1 { +template<typename T> struct RetainPtr { + RetainPtr() {} +}; + + +RetainPtr<id<bork> > x; +RetainPtr<id> y; + +} |