diff options
author | Jason Merrill <jason@redhat.com> | 2016-07-22 03:57:43 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2016-07-22 03:57:43 +0000 |
commit | 252f1c0f23b0611f850dfa3f126c4a2902cf5b4a (patch) | |
tree | 0f92ad032c506b46b2114ffa550d4d51d3058856 | |
parent | 1e2677a5104344b11a66bbdbac4293ce218b2a45 (diff) |
PR c++/69223 - ICE with deduced template return type.
* semantics.c (apply_deduced_return_type): Call
complete_type_or_else before building the new RESULT_DECL.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@238631 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C | 15 |
3 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 553c2ba8fc7..db5eb75223b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-07-21 Jason Merrill <jason@redhat.com> + PR c++/69223 + * semantics.c (apply_deduced_return_type): Call + complete_type_or_else before building the new RESULT_DECL. + PR c++/71913 * call.c (unsafe_copy_elision_p): It's OK to elide when initializing an unknown object. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bc8fec1103b..7699765fe58 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10664,6 +10664,10 @@ apply_deduced_return_type (tree fco, tree return_type) if (TREE_TYPE (result) == return_type) return; + if (!processing_template_decl && !VOID_TYPE_P (return_type) + && !complete_type_or_else (return_type, NULL_TREE)) + return; + /* We already have a DECL_RESULT from start_preparsed_function. Now we need to redo the work it and allocate_struct_function did to reflect the new type. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C new file mode 100644 index 00000000000..68ac29c9eac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C @@ -0,0 +1,15 @@ +// PR c++/69223 +// { dg-do compile { target c++11 } } + +template <class T> struct A +{ + T x[20]; +}; + +int main() +{ + auto l = [](const A<int>& i){ return i; }; + A<int> a; + + l(a); +} |