summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-27 17:26:47 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-27 17:26:47 +0000
commit6ba0e3e2446e6ba2673b8d68fdb27019d000b668 (patch)
treead9af212272fe6c4dcdfb8c611671f528555e387
parent2538bd2e907580ba2d5ef3da8c0a0a9bb50c4d53 (diff)
downloadgcc-6ba0e3e2446e6ba2673b8d68fdb27019d000b668.tar.gz
PR c++/84489 - dependent default template argument
* pt.c (type_unification_real): Handle early substitution failure. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258039 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c21
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C10
3 files changed, 29 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index dd35f1bda52..b2973d1b301 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-27 Jason Merrill <jason@redhat.com>
+
+ PR c++/84489 - dependent default template argument
+ * pt.c (type_unification_real): Handle early substitution failure.
+
2018-02-26 Jason Merrill <jason@redhat.com>
PR c++/84560 - ICE capturing multi-dimensional VLA.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 42fd872d6c0..a3da40912d6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19831,21 +19831,28 @@ type_unification_real (tree tparms,
continue;
tree parm = TREE_VALUE (tparm);
- if (TREE_CODE (parm) == PARM_DECL
- && uses_template_parms (TREE_TYPE (parm))
- && saw_undeduced < 2)
- continue;
+ tsubst_flags_t fcomplain = complain;
+ if (saw_undeduced == 1)
+ {
+ /* When saw_undeduced == 1, substitution into parm and arg might
+ fail or not replace all template parameters, and that's
+ fine. */
+ fcomplain = tf_none;
+ if (TREE_CODE (parm) == PARM_DECL
+ && uses_template_parms (TREE_TYPE (parm)))
+ continue;
+ }
tree arg = TREE_PURPOSE (tparm);
reopen_deferring_access_checks (*checks);
location_t save_loc = input_location;
if (DECL_P (parm))
input_location = DECL_SOURCE_LOCATION (parm);
- arg = tsubst_template_arg (arg, full_targs, complain, NULL_TREE);
- if (!uses_template_parms (arg))
+ arg = tsubst_template_arg (arg, full_targs, fcomplain, NULL_TREE);
+ if (arg != error_mark_node && !uses_template_parms (arg))
arg = convert_template_argument (parm, arg, full_targs, complain,
i, NULL_TREE);
- else if (saw_undeduced < 2)
+ else if (saw_undeduced == 1)
arg = NULL_TREE;
else
arg = error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C
new file mode 100644
index 00000000000..636bf1afd88
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C
@@ -0,0 +1,10 @@
+// PR c++/84489
+// { dg-do compile { target c++11 } }
+
+template <class T = int, T N = T(), bool B = (N >> 1)>
+T f1() {return 0;}
+
+int main()
+{
+ f1(); // Bug here
+}