From edac124d95be8bd327fd5754651f4eb25f0a280b Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Fri, 15 Dec 2000 01:11:38 +0000 Subject: [PATCH] pt.c (check_explicit_specialization): Propagate default function arguments to explicit specializations. * pt.c (check_explicit_specialization): Propagate default function arguments to explicit specializations. * g++.old-deja/g++.pt/spec33.C: New test. From-SVN: r38266 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 25 +++++++++++++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.old-deja/g++.pt/spec33.C | 26 ++++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/spec33.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9c3fd361840a..07753bf41492 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-12-14 Kriang Lerdsuwanakij + + * pt.c (check_explicit_specialization): Propagate default + function arguments to explicit specializations. + 2000-12-13 DJ Delorie * typeck.c (build_binary_op): Do signed/unsigned warnings for >? diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a4463ebe48b3..34540a84b33d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1543,6 +1543,31 @@ check_explicit_specialization (declarator, decl, template_count, flags) last_function_parms = TREE_CHAIN (last_function_parms); } + /* Inherit default function arguments from the template + DECL is specializing. */ + { + tree t1 = TYPE_ARG_TYPES (TREE_TYPE (decl)); + tree t2 = TYPE_ARG_TYPES (TREE_TYPE (DECL_TEMPLATE_RESULT (tmpl))); + + /* DECL may contain more parameters than TMPL due to the extra + in-charge parameter in constructors and destructors. */ + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)) + t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2); + if (DECL_HAS_IN_CHARGE_PARM_P (decl)) + t1 = TREE_CHAIN (t1); + + /* Note that we do not need to reparse default arguments, + since explicit specialization cannot be declared in + class scope as in [temp.expl.spec]. */ + for (; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2)) + { + if (TREE_PURPOSE (t2)) + TREE_PURPOSE (t1) = TREE_PURPOSE (t2); + } + + my_friendly_assert (t1 == NULL_TREE && t2 == NULL_TREE, 20001211); + } + /* Set up the DECL_TEMPLATE_INFO for DECL. */ DECL_TEMPLATE_INFO (decl) = tree_cons (tmpl, targs, NULL_TREE); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b47b75b71ffc..a12aab2af50e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-12-14 Kriang Lerdsuwanakij + + * g++.old-deja/g++.pt/spec33.C: New test. + 2000-12-14 Catherine Moore * gcc.c-torture/execute/920501-7.c: Check for NO_TRAMPOLINES. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec33.C b/gcc/testsuite/g++.old-deja/g++.pt/spec33.C new file mode 100644 index 000000000000..a458c1dc417c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec33.C @@ -0,0 +1,26 @@ +// Build don't link: +// Origin: James McKelvey + +class A +{ + public: + template A(T x, bool y = false); +}; + +template A::A(T, bool) +{ +} + +template <> A::A(char, bool) +{ +} + +int main() +{ + int b; + char c; + + A x(b); + A y(c); + A z(c, false); +} -- 2.43.5