From: Dodji Seketeli Date: Wed, 13 Jan 2010 20:06:26 +0000 (+0000) Subject: re PR c++/42634 (ICE with -g -O2 -std=c++0x in copy_fn_p, at cp/decl.c:9973) X-Git-Tag: releases/gcc-4.5.0~1251 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5859aaf073f326545266b691f5d74fc0f2f0f11;p=thirdparty%2Fgcc.git re PR c++/42634 (ICE with -g -O2 -std=c++0x in copy_fn_p, at cp/decl.c:9973) Fix PR c++/42634 gcc/cp/ChangeLog: PR c++/42634 * error.c (dump_template_parms): Use innermost template arguments before calling count_non_default_template_args. (count_non_default_template_args): We are being called with template innermost arguments now. There is no need to ensure that again. gcc/testsuite/ChangeLog: PR c++/42634 * g++.dg/template/error45.C: New test. From-SVN: r155868 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07a3486a4042..11fa60d3a16b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2010-01-13 Dodji Seketeli + + PR c++/42634 + * error.c (dump_template_parms): Use innermost template + arguments before calling count_non_default_template_args. + (count_non_default_template_args): We are being called with + template innermost arguments now. There is no need to ensure + that again. + 2010-01-07 Dodji Seketeli c++/40155 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e0e5ae52ceb7..54e96810f9bc 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -165,8 +165,7 @@ dump_template_argument (tree arg, int flags) static int count_non_default_template_args (tree args, tree params, int flags) { - tree inner_args = INNERMOST_TEMPLATE_ARGS (args); - int n = TREE_VEC_LENGTH (inner_args); + int n = TREE_VEC_LENGTH (args); int last; if (params == NULL_TREE @@ -195,7 +194,7 @@ count_non_default_template_args (tree args, tree params, int flags) NULL_TREE, false, true); --processing_template_decl; } - if (!cp_tree_equal (TREE_VEC_ELT (inner_args, last), def)) + if (!cp_tree_equal (TREE_VEC_ELT (args, last), def)) break; } @@ -1492,9 +1491,9 @@ dump_template_parms (tree info, int primary, int flags) ? DECL_INNERMOST_TEMPLATE_PARMS (TI_TEMPLATE (info)) : NULL_TREE); + args = INNERMOST_TEMPLATE_ARGS (args); len = count_non_default_template_args (args, params, flags); - args = INNERMOST_TEMPLATE_ARGS (args); for (ix = 0; ix != len; ix++) { tree arg = TREE_VEC_ELT (args, ix); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5bce27b598bc..85dd4e08f26b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-01-13 Dodji Seketeli + + PR c++/42634 + * g++.dg/template/error45.C: New test. + 2010-01-13 Martin Jambor PR tree-optimization/42704 diff --git a/gcc/testsuite/g++.dg/template/error45.C b/gcc/testsuite/g++.dg/template/error45.C new file mode 100644 index 000000000000..3bd8fb4e714b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error45.C @@ -0,0 +1,35 @@ +// Contributed by Dodji Seketeli +// Origin PR c++/42634 +// { dg-options "-g -std=gnu++0x" } +// { dg-do compile } + +template T declval(); + +template struct is_constructible { + template static decltype(T1(declval()...), char()) test(); + static const bool value = sizeof(test()) == 1; +}; +template struct enable_if { + typedef void type; +}; +template struct pair { + template::value>::type + > + pair(const T1&, U2&&) { } +}; +struct string { + string() : p(0) {} + char* p; +}; + +struct Foo { + string s; + int i; +}; + +void f() +{ + pair(1, Foo()); +} +