This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/49554 (bogus error with lambda in template)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 29 Jun 2011 17:16:41 -0400
- Subject: Re: C++ PATCH for c++/49554 (bogus error with lambda in template)
- References: <4E0B5FD9.7090002@redhat.com>
While looking at this issue, I also noticed that we were substituting
into DECL_INITIAL more than we need to.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 327bbebe3243b0423932862d3d12f92928853e9c
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 29 14:21:17 2011 -0400
* pt.c (tsubst_decl) [VAR_DECL]: In unevaluated operand,
don't tsubst DECL_INITIAL unless our type use auto.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d1d8336..dc6cd50 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10138,12 +10138,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
scope, such as for a lambda return type. Don't add it to
local_specializations, do perform auto deduction. */
tree auto_node = type_uses_auto (type);
- tree init
- = tsubst_expr (DECL_INITIAL (t), args, complain, in_decl,
- /*constant_expression_p=*/false);
-
- if (auto_node && init)
+ if (auto_node)
{
+ tree init
+ = tsubst_expr (DECL_INITIAL (t), args, complain, in_decl,
+ /*constant_expression_p=*/false);
init = resolve_nondeduced_context (init);
TREE_TYPE (r) = type
= do_auto_deduction (type, init, auto_node);