re PR c++/40371 (ICE with template operator)

cp/
2009-11-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/40371
	* call.c (add_template_candidate_real): Early return NULL if
	the arglist length is smaller than skip_without_in_chrg; tidy.

testsuite/
2009-11-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/40371
	* g++.dg/template/crash93.C: New.

From-SVN: r154852
This commit is contained in:
Paolo Carlini 2009-11-30 22:45:06 +00:00 committed by Paolo Carlini
parent ed807d06d9
commit 9c39ceab1a
4 changed files with 31 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2009-11-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/40371
* call.c (add_template_candidate_real): Early return NULL if
the arglist length is smaller than skip_without_in_chrg; tidy.
2009-11-30 Dodji Seketeli <dodji@redhat.com>
PR c++/42069

View File

@ -2457,9 +2457,10 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
{
int ntparms = DECL_NTPARMS (tmpl);
tree targs = make_tree_vec (ntparms);
unsigned int nargs;
int skip_without_in_chrg;
tree first_arg_without_in_chrg;
unsigned int len = VEC_length (tree, arglist);
unsigned int nargs = (first_arg == NULL_TREE ? 0 : 1) + len;
unsigned int skip_without_in_chrg = 0;
tree first_arg_without_in_chrg = first_arg;
tree *args_without_in_chrg;
unsigned int nargs_without_in_chrg;
unsigned int ia, ix;
@ -2468,12 +2469,6 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
int i;
tree fn;
nargs = (first_arg == NULL_TREE ? 0 : 1) + VEC_length (tree, arglist);
skip_without_in_chrg = 0;
first_arg_without_in_chrg = first_arg;
/* We don't do deduction on the in-charge parameter, the VTT
parameter or 'this'. */
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (tmpl))
@ -2494,9 +2489,11 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
++skip_without_in_chrg;
}
if (len < skip_without_in_chrg)
return NULL;
nargs_without_in_chrg = ((first_arg_without_in_chrg != NULL_TREE ? 1 : 0)
+ (VEC_length (tree, arglist)
- skip_without_in_chrg));
+ (len - skip_without_in_chrg));
args_without_in_chrg = XALLOCAVEC (tree, nargs_without_in_chrg);
ia = 0;
if (first_arg_without_in_chrg != NULL_TREE)

View File

@ -1,3 +1,8 @@
2009-11-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/40371
* g++.dg/template/crash93.C: New.
2009-11-30 Steve Ellcey <sje@cup.hp.com>
* gcc.dg/pr41551.c: New test.

View File

@ -0,0 +1,12 @@
// PR c++/40371
struct A
{
typedef void (&F)();
template<int> operator F();
};
void foo()
{
A()(); // { dg-error "no match" }
}