From 18802917af53a9423fe496aa68cf6c2aa67f8ca9 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 9 Sep 2008 17:41:58 -0400 Subject: [PATCH] re PR c++/37439 (ICE using auto return-type in template function) PR c++/37439 * pt.c (tsubst_copy) [PARM_DECL]: Don't abort if the parm has DECL_CONTEXT set. From-SVN: r140176 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp0x/auto6.C | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index be42b37cbfdc..9760ccfca040 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-09-09 Jason Merrill + + PR c++/37439 + * pt.c (tsubst_copy) [PARM_DECL]: Don't abort if the parm has + DECL_CONTEXT set. + 2008-09-09 Jakub Jelinek PR c++/37389 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4aa7b1ad146c..cdaae59914e2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9809,7 +9809,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) Replace it with an arbitrary expression with the same type (*(T*)0). This should only occur in an unevaluated context (i.e. decltype). */ - gcc_assert (skip_evaluation && DECL_CONTEXT (t) == NULL_TREE); + gcc_assert (skip_evaluation); r = non_reference (TREE_TYPE (t)); r = tsubst (r, args, complain, in_decl); r = build_pointer_type (r); diff --git a/gcc/testsuite/g++.dg/cpp0x/auto6.C b/gcc/testsuite/g++.dg/cpp0x/auto6.C index a574f54758f7..713583a1a48a 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto6.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto6.C @@ -6,7 +6,10 @@ auto f() -> int } template -auto add(T t, U u) -> decltype (t+u); +auto add(T t, U u) -> decltype (t+u) +{ + return t+u; +} template decltype(T()+U()) add2(T t, U u); -- 2.47.2