Clang error: no function template matches function template specialization A (err_function_template_spec_no_match)
Jump to navigation
Jump to search
Text | error: no function template matches function template specialization A |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_function_template_spec_no_match |
Internal Message | no function template matches function template specialization %0
|
Regular Expression | (?:error|fatal error)\: no function template matches function template specialization (.*?)
|
First Commit | 2009-09-25 3a923c2d3799 WIP implementation of explicit function template specialization. This |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
// Template specialization without original template definition
template<> void f<double>();
| |
Compiler Output |
<source>:3:17: error: no function template matches function template specialization 'f' |
Clang Internals (17.0.6)
Git Commit Message
WIP implementation of explicit function template specialization. This first implementation recognizes when a function declaration is an explicit function template specialization (based on the presence of a template<> header), performs template argument deduction + ambiguity resolution to determine which template is being specialized, and hooks There are many caveats here: - We completely and totally drop any explicitly-specified template arguments on the floor - We don't diagnose any of the extra semantic things that we should diagnose. - I haven't looked to see that we're getting the right linkage for explicit specializations On a happy note, this silences a bunch of errors that show up in libstdc++'s <iostream>, although Clang still can't get through the entire header. llvm-svn: 82728
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaTemplate.cpp (line 9496)
/// Perform semantic analysis for the given function template
/// specialization.
///
/// This routine performs all of the semantic analysis required for an
/// explicit function template specialization. On successful completion,
/// the function declaration \p FD will become a function template
/// specialization.
///
/// \param FD the function declaration, which will be updated to become a
/// function template specialization.
///
/// \param ExplicitTemplateArgs the explicitly-provided template arguments,
/// if any. Note that this may be valid info even when 0 arguments are
/// explicitly provided as in, e.g., \c void sort<>(char*, char*);
/// as it anyway contains info on the angle brackets locations.
///
/// \param Previous the set of declarations that may be specialized by
/// this function specialization.
///
/// \param QualifiedFriend whether this is a lookup for a qualified friend
/// declaration with no explicit template argument list that might be
/// befriending a function template specialization.
bool Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend) {
// ...
UnresolvedSetIterator Result = getMostSpecialized(Candidates.begin(), Candidates.end(), FailedCandidates, FD->getLocation(), PDiag(diag::err_function_template_spec_no_match) << FD->getDeclName(), PDiag(diag::err_function_template_spec_ambiguous) << FD->getDeclName() << (ExplicitTemplateArgs != nullptr), PDiag(diag::note_function_template_spec_matched));
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp
- clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp:44:8: error: no function template matches function template specialization 'f'