diff mbox

C++ PATCH to generic lambda conversion operator

Message ID CADzB+2nWySvW7Y6m1CKdCyjcoRHYnhN=yLgerXZPS4sGqSEDEQ@mail.gmail.com
State New
Headers show

Commit Message

Jason Merrill July 8, 2016, 9:28 p.m. UTC
While working on another patch, I noticed that the dummy object used
for a generic lambda conversion operator was mistakenly created by
casting nullptr to the lambda closure type, rather than a pointer to
that type.  Fixed thus.
commit 972a2e5d623b46b32f9de4633b60d5ecf95fc5df
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jul 7 17:03:57 2016 -0400

    	* lambda.c (maybe_add_lambda_conv_op): Fix null object argument.
diff mbox

Patch

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 85ad9f8..3822882 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -904,6 +904,8 @@  maybe_add_lambda_conv_op (tree type)
   tree optype = TREE_TYPE (callop);
   tree fn_result = TREE_TYPE (optype);
 
+  tree thisarg = build_nop (TREE_TYPE (DECL_ARGUMENTS (callop)),
+			    null_pointer_node);
   if (generic_lambda_p)
     {
       /* Prepare the dependent member call for the static member function
@@ -911,7 +913,8 @@  maybe_add_lambda_conv_op (tree type)
 	 return expression for a deduced return call op to allow for simple
 	 implementation of the conversion operator.  */
 
-      tree instance = build_nop (type, null_pointer_node);
+      tree instance = cp_build_indirect_ref (thisarg, RO_NULL,
+					     tf_warning_or_error);
       tree objfn = build_min (COMPONENT_REF, NULL_TREE,
 			      instance, DECL_NAME (callop), NULL_TREE);
       int nargs = list_length (DECL_ARGUMENTS (callop)) - 1;
@@ -923,9 +926,7 @@  maybe_add_lambda_conv_op (tree type)
   else
     {
       direct_argvec = make_tree_vector ();
-      direct_argvec->quick_push (build1 (NOP_EXPR,
-					 TREE_TYPE (DECL_ARGUMENTS (callop)),
-					 null_pointer_node));
+      direct_argvec->quick_push (thisarg);
     }
 
   /* Copy CALLOP's argument list (as per 'copy_list') as FN_ARGS in order to