diff options
author | Jason Merrill <jason@gcc.gnu.org> | 2008-11-20 13:40:52 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2008-11-20 13:40:52 -0500 |
commit | c7962e7d5dc3ccbbd1a0454eab655e50a7e78049 (patch) | |
tree | cc8c1f53289edaf65ceafe1ed81a4ce5b237f004 | |
parent | 19523300a00967225f9d377b241c8442aa261792 (diff) | |
download | gcc-c7962e7d5dc3ccbbd1a0454eab655e50a7e78049.zip gcc-c7962e7d5dc3ccbbd1a0454eab655e50a7e78049.tar.gz gcc-c7962e7d5dc3ccbbd1a0454eab655e50a7e78049.tar.bz2 |
re PR c++/37540 (ICE on __decltype of method call in function template)
PR c++/37540
* call.c (build_over_call): Take the address of the function even
in a template.
(build_new_method_call): Remember the type of the called function
in a template.
From-SVN: r142054
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/call.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype14.C | 17 |
4 files changed, 42 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fe2eab6..558682b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2008-11-20 Jason Merrill <jason@redhat.com> + + PR c++/37540 + * call.c (build_over_call): Take the address of the function even + in a template. + (build_new_method_call): Remember the type of the called function + in a template. + 2008-11-19 Dodji Seketeli <dodji@redhat.com> PR c++/37142 @@ -8,7 +16,7 @@ PR c++/35405 * pt.c (lookup_template_class): Check pointers before dereferencing - Them. + them. * error.c (dump_template_decl): Likewise. 2008-11-19 Jason Merrill <jason@redhat.com> diff --git a/gcc/cp/call.c b/gcc/cp/call.c index af3fd99..bbd6a22 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5103,7 +5103,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) tree expr; tree return_type; return_type = TREE_TYPE (TREE_TYPE (fn)); - expr = build_call_list (return_type, fn, args); + expr = build_call_list (return_type, build_addr_func (fn), args); if (TREE_THIS_VOLATILE (fn) && cfun) current_function_returns_abnormally = 1; if (!VOID_TYPE_P (return_type)) @@ -5964,10 +5964,16 @@ build_new_method_call (tree instance, tree fns, tree args, } if (processing_template_decl && call != error_mark_node) - call = (build_min_non_dep_call_list - (call, - build_min_nt (COMPONENT_REF, orig_instance, orig_fns, NULL_TREE), - orig_args)); + { + if (TREE_CODE (call) == INDIRECT_REF) + call = TREE_OPERAND (call, 0); + call = (build_min_non_dep_call_list + (call, + build_min (COMPONENT_REF, TREE_TYPE (CALL_EXPR_FN (call)), + orig_instance, orig_fns, NULL_TREE), + orig_args)); + call = convert_from_reference (call); + } /* Free all the conversions we allocated. */ obstack_free (&conversion_obstack, p); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 569accd..43454d2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-11-20 Jason Merrill <jason@redhat.com> + + PR c++/37540 + * g++.dg/cpp0x/decltype14.C: New test. + 2008-11-20 Richard Guenther <rguenther@suse.de> PR tree-optimization/37868 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype14.C b/gcc/testsuite/g++.dg/cpp0x/decltype14.C new file mode 100644 index 0000000..9484173 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype14.C @@ -0,0 +1,17 @@ +// PR c++/37540 + +struct A +{ + int g() {return 0;} +}; + +template <typename T_> +void f(A a) +{ + __decltype(a.g()) i; +} + +int main() +{ + f<int>(A()); +} |