diff options
author | Jason Merrill <jason@redhat.com> | 2009-10-12 17:04:27 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-10-12 17:04:27 -0400 |
commit | 23f392e0191bc5d193c1cdbacc92fa4814078eb1 (patch) | |
tree | 110b3db4a3c8cbb454577a847db0985c28ee48ab | |
parent | 610bf3ebef5b6e06e554736ccadd9b76371be14a (diff) | |
download | gcc-23f392e0191bc5d193c1cdbacc92fa4814078eb1.zip gcc-23f392e0191bc5d193c1cdbacc92fa4814078eb1.tar.gz gcc-23f392e0191bc5d193c1cdbacc92fa4814078eb1.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/pt.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C | 7 |
4 files changed, 27 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d2a46b2..07dc96a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2009-10-12 Jason Merrill <jason@redhat.com> + + 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 <jason@redhat.com> PR c++/37204 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 148adab..084ad1c 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 5e5f39c..e9ca25b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-10-12 Jason Merrill <jason@redhat.com> + + PR c++/37766 + * g++.dg/cpp0x/fntmpdefarg1.C: New. + 2009-10-12 Janis Johnson <janis187@us.ibm.com> * 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 0000000..25192ad --- /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<int& b = a> void f() { + f<>(); +} |