// FIXME: make a note of the failed deduction for diagnostics.
(void)Result;
} else {
- // FIXME: If the match isn't exact, shouldn't we just drop this as
- // a candidate? Find a testcase before changing the code.
+ // Template argument deduction ensures that we have an exact match.
+ // This function template specicalization works.
assert(FunctionType
== Context.getCanonicalType(Specialization->getType()));
Matches.push_back(std::make_pair(I.getPair(),
Deduced, 0))
return Result;
}
-
- return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
- NumExplicitlySpecified,
- Specialization, Info);
+
+ if (TemplateDeductionResult Result
+ = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
+ NumExplicitlySpecified,
+ Specialization, Info))
+ return Result;
+
+ // If the requested function type does not match the actual type of the
+ // specialization, template argument deduction fails.
+ if (!ArgFunctionType.isNull() &&
+ !Context.hasSameType(ArgFunctionType, Specialization->getType()))
+ return TDK_NonDeducedMismatch;
+
+ return TDK_Success;
}
/// \brief Deduce template arguments for a templated conversion
// expected-error{{cannot initialize a variable of type}}
}
+
+namespace PR8196 {
+ template <typename T> struct mcdata {
+ typedef int result_type;
+ };
+ template <class T>
+ typename mcdata<T>::result_type wrap_mean(mcdata<T> const&);
+ void add_property(double(*)(mcdata<double> const &)); // expected-note{{candidate function not viable: no overload of 'wrap_mean' matching}}
+ void f() {
+ add_property(&wrap_mean); // expected-error{{no matching function for call to 'add_property'}}
+ }
+}