aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-11-30 22:45:06 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-11-30 22:45:06 +0000
commit9c39ceab1a91f8f95ec0b44e1388832e6f91e0d3 (patch)
tree06c044f6f408e24cdc5701b20098e4130bc7fe33 /gcc
parented807d06d99b37641fbcc4fa0967b4f8957b9017 (diff)
downloadgcc-9c39ceab1a91f8f95ec0b44e1388832e6f91e0d3.zip
gcc-9c39ceab1a91f8f95ec0b44e1388832e6f91e0d3.tar.gz
gcc-9c39ceab1a91f8f95ec0b44e1388832e6f91e0d3.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c19
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/crash93.C12
4 files changed, 31 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e035f3d..0be2491 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 70a5b1e..837a65d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5db13f2..a7d248f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/template/crash93.C b/gcc/testsuite/g++.dg/template/crash93.C
new file mode 100644
index 0000000..696a04a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/crash93.C
@@ -0,0 +1,12 @@
+// PR c++/40371
+
+struct A
+{
+ typedef void (&F)();
+ template<int> operator F();
+};
+
+void foo()
+{
+ A()(); // { dg-error "no match" }
+}