if (ParamQs.hasObjCLifetime())
DeducedQs.removeObjCLifetime();
+ // Objective-C ARC:
+ // If template deduction would produce a lifetime qualifier on a type
+ // that is not a lifetime type, template argument deduction fails.
+ if (ParamQs.hasObjCLifetime() && !DeducedType->isObjCLifetimeType() &&
+ !DeducedType->isDependentType()) {
+ Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->getParam(Index));
+ Info.FirstArg = TemplateArgument(Param);
+ Info.SecondArg = TemplateArgument(Arg);
+ return Sema::TDK_Underqualified;
+ }
+
// Objective-C ARC:
// If template deduction would produce an argument type with lifetime type
// but no lifetime qualifier, the __strong lifetime qualifier is inferred.
float &fr3 = qual_vs_unqual_ref(*aap);
float &fr4 = qual_vs_unqual_ref(*uap);
}
+
+namespace rdar9828157 {
+ // Template argument deduction involving lifetime qualifiers and
+ // non-lifetime types.
+ class A { };
+
+ template<typename T> float& f(T&);
+ template<typename T> int& f(__strong T&);
+ template<typename T> double& f(__weak T&);
+
+ void test_f(A* ap) {
+ float &fr = (f)(ap);
+ }
+}