From 23f392e0191bc5d193c1cdbacc92fa4814078eb1 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 12 Oct 2009 17:04:27 -0400 Subject: [PATCH] re PR c++/37766 ([C++0x] ICE with function's default reference template parameter) PR c++/37766 * pt.c (type_unification_real): Call convert_template_argument for function default template arguments. (check_default_tmpl_args): Suggest -std=c++0x when function default template args seen in C++98 mode. From-SVN: r152685 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/pt.c | 11 +++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C | 7 +++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d2a46b2b1b2..07dc96ae826 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2009-10-12 Jason Merrill + + PR c++/37766 + * pt.c (type_unification_real): Call convert_template_argument + for function default template arguments. + (check_default_tmpl_args): Suggest -std=c++0x when function default + template args seen in C++98 mode. + 2009-10-11 Jason Merrill PR c++/37204 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 148adab2cba..084ad1cb09f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4025,7 +4025,8 @@ check_default_tmpl_args (tree decl, tree parms, int is_primary, else if (is_friend_decl) msg = "default template arguments may not be used in function template friend declarations"; else if (TREE_CODE (decl) == FUNCTION_DECL && (cxx_dialect == cxx98)) - msg = "default template arguments may not be used in function templates"; + msg = ("default template arguments may not be used in function templates " + "without -std=c++0x or -std=gnu++0x"); else if (is_partial) msg = "default template arguments may not be used in partial specializations"; else @@ -13178,9 +13179,11 @@ type_unification_real (tree tparms, to explicitly check cxx_dialect here. */ if (TREE_PURPOSE (TREE_VEC_ELT (tparms, i))) { - tree arg = tsubst_template_arg - (TREE_PURPOSE (TREE_VEC_ELT (tparms, i)), - targs, tf_none, NULL_TREE); + tree parm = TREE_VALUE (TREE_VEC_ELT (tparms, i)); + tree arg = TREE_PURPOSE (TREE_VEC_ELT (tparms, i)); + arg = tsubst_template_arg (arg, targs, tf_none, NULL_TREE); + arg = convert_template_argument (parm, arg, targs, tf_none, + i, NULL_TREE); if (arg == error_mark_node) return 1; else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5e5f39c7457..e9ca25b8e52 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-10-12 Jason Merrill + + PR c++/37766 + * g++.dg/cpp0x/fntmpdefarg1.C: New. + 2009-10-12 Janis Johnson * gcc.dg/lto/20090914-2.c: Fix typos in test directives. diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C new file mode 100644 index 00000000000..25192ad8672 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C @@ -0,0 +1,7 @@ +// PR c++/37766 +// { dg-options -std=c++0x } + +int a = 1; +template void f() { + f<>(); +}