Patchwork C++ PATCH for c++/49554 (bogus error with lambda in template)

login
register
mail settings
Submitter Jason Merrill
Date June 29, 2011, 9:16 p.m.
Message ID <4E0B9639.30607@redhat.com>
Download mbox | patch
Permalink /patch/102668/
State New
Headers show

Comments

Jason Merrill - June 29, 2011, 9:16 p.m.
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.

Patch

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);