++header_count;
tree orig_fns = fns;
+ bool header_mismatch = false;
if (variable_template_p (fns))
{
specialization but rather a template instantiation, so there
is no check we can perform here. */
if (header_count && header_count != template_count + 1)
- continue;
+ {
+ header_mismatch = true;
+ continue;
+ }
/* Check that the number of template arguments at the
innermost level for DECL is the same as for FN. */
{
error ("template-id %qD for %q+D does not match any template "
"declaration", template_id, decl);
- if (header_count && header_count != template_count + 1)
+ if (header_mismatch)
inform (DECL_SOURCE_LOCATION (decl),
"saw %d %<template<>%>, need %d for "
"specializing a member function template",
header_count, template_count + 1);
- else
- print_candidates (orig_fns);
+ print_candidates (orig_fns);
return error_mark_node;
}
else if ((templates && TREE_CHAIN (templates))
--- /dev/null
+// PR c++/94529
+
+template <class T>
+struct foo {
+ // the issue is const here
+ void bar(T& foobar) const { foobar = 0; } // { dg-message "candidate" }
+};
+
+template <> void
+foo<int>::bar(int& foobar) { foobar = 9; } // { dg-error "does not match" }
+// { dg-bogus "member function template" "" { target *-*-* } .-1 }