From 2260254428715fe4b137b2e1b08ab44d93b14b09 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 14 Dec 2016 16:45:33 +0000 Subject: [PATCH] PR c++/78701 * pt.c (type_unification_real): Check tsubst arg doesn't have remaining template parms before converting it. PR c++/78701 * g++.dg/cpp0x/pr78701.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243657 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 12 ++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/pr78701.C | 9 +++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr78701.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3404e88ed61..4061bedab8b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-12-14 Nathan Sidwell + PR c++/78701 + * pt.c (type_unification_real): Check tsubst arg doesn't have + remaining template parms before converting it. + PR c++/69481 * cp-tree.h (TYPE_TEMPLATE_INFO_MAYBE_ALIAS): Always use TYPE_ALIAS_TEMPLATE_INFO for aliases. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bae96ec9d22..a45e99cc596 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18991,14 +18991,19 @@ type_unification_real (tree tparms, if (DECL_P (parm)) input_location = DECL_SOURCE_LOCATION (parm); arg = tsubst_template_arg (arg, full_targs, complain, NULL_TREE); - arg = convert_template_argument (parm, arg, full_targs, complain, - i, NULL_TREE); + if (!uses_template_parms (arg)) + arg = convert_template_argument (parm, arg, full_targs, complain, + i, NULL_TREE); + else if (saw_undeduced < 2) + arg = NULL_TREE; + else + arg = error_mark_node; input_location = save_loc; *checks = get_deferred_access_checks (); pop_deferring_access_checks (); if (arg == error_mark_node) return 1; - else + else if (arg) { TREE_VEC_ELT (targs, i) = arg; /* The position of the first default template argument, @@ -19006,7 +19011,6 @@ type_unification_real (tree tparms, Record that. */ if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs)) SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs, i); - continue; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f7fa7e43c7..47a98ac1a01 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-14 Nathan Sidwell + + PR c++/78701 + * g++.dg/cpp0x/pr78701.C: New. + 2016-12-14 Michael Meissner * gcc/testsuite/gcc.target/powerpc/vec-extract.h: If DO_TRACE is diff --git a/gcc/testsuite/g++.dg/cpp0x/pr78701.C b/gcc/testsuite/g++.dg/cpp0x/pr78701.C new file mode 100644 index 00000000000..6fef926876b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr78701.C @@ -0,0 +1,9 @@ +// PR c++/58707 +// { dg-do compile { target c++11 } } + +// ICE during deduction of default parms + +template + void f(T x) {} + +template void f (int); -- 2.11.4.GIT