Restore status-quo how function template specializations were diagnosed.
Signed-off-by: Matthias Kretz <m.kr...@gsi.de>
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/default-template-args-1.C: Adjust for
different presentation of function template specializations.
* g++.dg/ext/pretty1.C: Ditto.
* g++.old-deja/g++.ext/pretty3.C: Ditto.
* g++.old-deja/g++.pt/memtemp77.C: Ditto.
gcc/cp/ChangeLog:
* error.c (dump_function_decl): Pretty print all template
specializations.
(dump_function_name): Only print template parms if given a
function template specialization.
---
gcc/cp/error.c | 18 ++++++++++--------
.../diagnostic/default-template-args-1.C | 4 ++--
gcc/testsuite/g++.dg/ext/pretty1.C | 2 +-
gcc/testsuite/g++.old-deja/g++.ext/pretty3.C | 2 +-
gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C | 2 +-
5 files changed, 15 insertions(+), 13 deletions(-)
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
stdₓ::simd
──────────────────────────────────────────────────────────────────────────
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> (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 <class T> void f(T)' is 'f' and not 'f<T>'), 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<class T> struct X { friend void foo<T>(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<float>(1); // { dg-warning "'void f3<a>\\(a\\) .with a = float.'" }
f3<float, 2>(1); // { dg-warning "'void f3<a, b>\\(a\\) .with a = float; int b = 2.'" }
f4(1.); // { dg-warning "'void f4\\(a\\) .with a = double.'" }
- f4(1); // { dg-warning "'void f4<int>\\(int\\)'" }
- f4(1.f); // { dg-warning "'void f4\\(float\\)'" }
+ f4(1); // { dg-warning "'void f4<a>\\(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>\\(int\\)" } }
+// { dg-final { scan-assembler "int bar<T>\\(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> (int)
if (strcmp (function, "f1<int>"))
bad = true;
- if (strcmp (pretty, "void f1<int>(int)"))
+ if (strcmp (pretty, "void f1<T>(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<char>::h(int) { return __PRETTY_FUNCTION__; }
int main()
{
if (strcmp (S3<double>::h(7),
- "static const char* S3<double>::h(int)") == 0)
+ "static const char* S3<T>::h(U) [with U = int; T = double]") == 0)
return 0;
else
return 1;