http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0961r1.html
I don't believe an actual defect report was filed for this, but the paper (in the "wording" section) claims that we should back-port this to C++17 as if it were a defect report. Besides that, this is pretty straightforward.
Thanks for taking a look!
Erik
You should use D->getUnderlyingDecl() rather than just D here, otherwise you'll reject this:
... because D will be a UsingShadowDecl not a FunctionTemplateDecl. (Please also add a corresponding testcase.)