diff --git a/gcc/cp/error.c b/gcc/cp/error.c index fb62adbeb0b..9365e42dd76 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1723,9 +1723,8 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) tree specialized_t = t; int specialized_flags = 0; - /* Pretty print only template instantiations. Don't pretty print explicit - specializations like 'template <> void fun (int)'. */ - if (DECL_TEMPLATE_INSTANTIATION (t) && DECL_TEMPLATE_INFO (t) + /* Pretty print template instantiations only. */ + if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t) && !(flags & TFF_NO_TEMPLATE_BINDINGS) && flag_pretty_templates) { @@ -1989,9 +1988,11 @@ dump_function_name (cxx_pretty_printer *pp, tree t, int flags) dump_module_suffix (pp, t); /* Print function template parameters if: - 1. t is template, and - 2. the caller didn't request to only print the template-name, and - 3. t actually has template parameters that are not indirect parameters from + 1. t is a template, and + 2. t is a specialization of a template (so that __FUNCTION__ of + 'template void f(T)' is 'f' and not 'f'), and + 3. the caller didn't request to only print the template-name, and + 4. t actually has template parameters that are not indirect parameters from enclosing scopes, i.e. either - t is a friend template specialization (eg. template struct X { friend void foo(int); }; since @@ -1999,7 +2000,7 @@ dump_function_name (cxx_pretty_printer *pp, tree t, int flags) before PRIMARY_TEMPLATE_P is safe to call), or - t is a primary template (own template header), and - 4. either + 5. either - flags requests to show no function arguments, in which case deduced types could be hidden and thus need to be printed, or - at least one function template argument was given explicitly and the @@ -2009,6 +2010,7 @@ dump_function_name (cxx_pretty_printer *pp, tree t, int flags) dump_template_parms. */ if (DECL_TEMPLATE_INFO (t) + && DECL_USE_TEMPLATE (t) && !(flags & TFF_TEMPLATE_NAME) && (TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t))) @@ -2016,7 +2018,7 @@ dump_function_name (cxx_pretty_printer *pp, tree t, int flags) || (DECL_TI_ARGS (t) && EXPLICIT_TEMPLATE_ARGS_P (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (t)))))) - dump_template_parms (pp, DECL_TEMPLATE_INFO (t), !DECL_USE_TEMPLATE (t), flags); + dump_template_parms (pp, DECL_TEMPLATE_INFO (t), false, flags); } /* Dump the template parameters from the template info INFO under control of diff --git a/gcc/testsuite/g++.dg/diagnostic/default-template-args-1.C b/gcc/testsuite/g++.dg/diagnostic/default-template-args-1.C index 6481798a69b..1b82ea46bb5 100644 --- a/gcc/testsuite/g++.dg/diagnostic/default-template-args-1.C +++ b/gcc/testsuite/g++.dg/diagnostic/default-template-args-1.C @@ -43,8 +43,8 @@ int main() f3(1); // { dg-warning "'void f3\\(a\\) .with a = float.'" } f3(1); // { dg-warning "'void f3\\(a\\) .with a = float; int b = 2.'" } f4(1.); // { dg-warning "'void f4\\(a\\) .with a = double.'" } - f4(1); // { dg-warning "'void f4\\(int\\)'" } - f4(1.f); // { dg-warning "'void f4\\(float\\)'" } + f4(1); // { dg-warning "'void f4\\(a\\) .with a = int.'" } + f4(1.f); // { dg-warning "'void f4\\(a\\) .with a = float.'" } f0(0); // { dg-error "" } f1(0); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/ext/pretty1.C b/gcc/testsuite/g++.dg/ext/pretty1.C index c5bfd6082a7..07cc9a6f2cd 100644 --- a/gcc/testsuite/g++.dg/ext/pretty1.C +++ b/gcc/testsuite/g++.dg/ext/pretty1.C @@ -60,7 +60,7 @@ __assert_fail (const char *cond, const char *file, unsigned int line, abort (); } -// { dg-final { scan-assembler "int bar\\(int\\)" } } +// { dg-final { scan-assembler "int bar\\(T\\).*with T = int" } } // { dg-final { scan-assembler "top level" } } // { dg-final { scan-assembler "int main\\(\\)" } } // { dg-final { scan-assembler "int bar\\(T\\).*with T = double" } } diff --git a/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C b/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C index 30c7ecd5065..6c82f5b6061 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C @@ -35,7 +35,7 @@ template<> void f1 (int) if (strcmp (function, "f1")) bad = true; - if (strcmp (pretty, "void f1(int)")) + if (strcmp (pretty, "void f1(T) [with T = int]")) bad = true; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C index 93dbf4b489f..6dd4b546c0c 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C @@ -19,7 +19,7 @@ const char* S3::h(int) { return __PRETTY_FUNCTION__; } int main() { if (strcmp (S3::h(7), - "static const char* S3::h(int)") == 0) + "static const char* S3::h(U) [with U = int; T = double]") == 0) return 0; else return 1;