From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CF349383AB49 for ; Thu, 15 Dec 2022 22:48:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF349383AB49 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671144482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3X1RHFLqfUGBMKY3Uoly2uzQmNX7ScChomJnVt680JI=; b=hK4D2LQI29JvLlAvU/X1CBlL8Hhtf/axg9ZaripFRjxJ8zGayxg1JVelooGj2pdE3MaiB0 gLGovJaHHSPwGU+ekO1Je6MBBquuE3xbnDn2g3ij/A/cF7difOWF+3dYREc4SqOw3EYzAM CE8PXgAxfpEO34zk8Y7dk8id+e0MeNg= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-347-2jnpivshPtO3rTJmn5OWcQ-1; Thu, 15 Dec 2022 17:37:18 -0500 X-MC-Unique: 2jnpivshPtO3rTJmn5OWcQ-1 Received: by mail-qt1-f199.google.com with SMTP id o9-20020ac841c9000000b003a820e4c248so553392qtm.2 for ; Thu, 15 Dec 2022 14:37:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3X1RHFLqfUGBMKY3Uoly2uzQmNX7ScChomJnVt680JI=; b=nD+kgf5tTe5KKhIlyjzY7f1JrdpsL8Tr4spI7kUWIAd/4g5nGY41U6c+A7Q8TToMbS E5NYzxAEMiSWjL3R5NXl6W2N9N8aS2mp3rw3/tdlwRHypjWTyz//FwH+hNqctg6uPnv2 dDJvj9MyX6t+BQEajtQogvgKHmlFaAN6dPlq5p4bgU/RoO8dQG55ld9++pAeWQwVZYHR X0pzMplVfV/YG8kj89nm5FbF0KquSdoOVwsmVTl5PHDN8BCw5Ti7eqcC0AEVnY6A1vM6 F+4UAwa/lssVHGYCedGPtjK2PQp4lJsTs1vEG81S9eYXu9uvj0K6Scf38lRHuPzJ/4hG p+DQ== X-Gm-Message-State: ANoB5pm9erX5JCHvCTvYJwRvv05X4lAuVHMj1S7zh1s9td3rIez9wcmD p2iVJoHOTbuXiTdSqm7RWOP8QRwkVddhtwuLS/nK4Irh4sD7mHNJ1yg2T9gZxrMELtShWmSE0Hy NGiM5yEnYufgwRomh/w== X-Received: by 2002:ac8:490d:0:b0:3a7:e6df:36c2 with SMTP id e13-20020ac8490d000000b003a7e6df36c2mr32337989qtq.56.1671143838160; Thu, 15 Dec 2022 14:37:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf42xpTe6DrPKQr7BV5mp3nBeUL38UGqjf8Sd57C04fYmIJPeZ/AzNip3yzY00kBP/YjSndYuA== X-Received: by 2002:ac8:490d:0:b0:3a7:e6df:36c2 with SMTP id e13-20020ac8490d000000b003a7e6df36c2mr32337963qtq.56.1671143837793; Thu, 15 Dec 2022 14:37:17 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id p16-20020a05620a057000b006fee9a70343sm182293qkp.14.2022.12.15.14.37.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 14:37:17 -0800 (PST) Message-ID: Date: Thu, 15 Dec 2022 17:37:16 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] coroutines: Build pointer initializers with nullptr_node [PR107768] To: iain@sandoe.co.uk, gcc-patches@gcc.gnu.org Cc: pinskia@gmail.com References: <20221210155427.31858-1-iain@sandoe.co.uk> From: Jason Merrill In-Reply-To: <20221210155427.31858-1-iain@sandoe.co.uk> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/10/22 10:54, Iain Sandoe wrote: > From: Andrew Pinski > > This is Andrew Pinski's patch, I just did testing, adjusted the test case and > provided the Changelog. > tested on x86-64-Darwin21, > OK for trunk? > Iain OK. > --- >8 --- > > The PR reports that using integer_zero_node triggers a warning for > -Wzero-as-null-pointer-constant which comes from compiler-generated code so > makes no sense to the end user. > > Co-Authored-By: Iain Sandoe > > PR c++/107768 > > gcc/cp/ChangeLog: > > * coroutines.cc (coro_rewrite_function_body): Initialize pointers > from nullptr_node. (morph_fn_to_coro): Likewise. > > gcc/testsuite/ChangeLog: > > * g++.dg/coroutines/pr107768.C: New test. > --- > gcc/cp/coroutines.cc | 6 ++--- > gcc/testsuite/g++.dg/coroutines/pr107768.C | 26 ++++++++++++++++++++++ > 2 files changed, 29 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/coroutines/pr107768.C > > diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc > index 3f23317a315..88d6c30d8b1 100644 > --- a/gcc/cp/coroutines.cc > +++ b/gcc/cp/coroutines.cc > @@ -4132,7 +4132,7 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig, > /* We will need to be able to set the resume function pointer to nullptr > to signal that the coroutine is 'done'. */ > tree zero_resume > - = build1 (CONVERT_EXPR, resume_fn_ptr_type, integer_zero_node); > + = build1 (CONVERT_EXPR, resume_fn_ptr_type, nullptr_node); > > /* The pointer to the destroy function. */ > tree var = coro_build_artificial_var (fn_start, coro_destroy_fn_id, > @@ -4519,7 +4519,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) > tree ramp_body = push_stmt_list (); > > tree zeroinit = build1_loc (fn_start, CONVERT_EXPR, > - coro_frame_ptr, integer_zero_node); > + coro_frame_ptr, nullptr_node); > tree coro_fp = coro_build_artificial_var (fn_start, "_Coro_frameptr", > coro_frame_ptr, orig, zeroinit); > tree varlist = coro_fp; > @@ -4754,7 +4754,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) > > gcc_checking_assert (same_type_p (fn_return_type, TREE_TYPE (grooaf))); > tree if_stmt = begin_if_stmt (); > - tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, integer_zero_node); > + tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, nullptr_node); > cond = build2 (EQ_EXPR, boolean_type_node, coro_fp, cond); > finish_if_stmt_cond (cond, if_stmt); > if (VOID_TYPE_P (fn_return_type)) > diff --git a/gcc/testsuite/g++.dg/coroutines/pr107768.C b/gcc/testsuite/g++.dg/coroutines/pr107768.C > new file mode 100644 > index 00000000000..22d7074f261 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/coroutines/pr107768.C > @@ -0,0 +1,26 @@ > +// { dg-additional-options "-Wzero-as-null-pointer-constant -fsyntax-only" } > + > +#include > + > +struct task > +{ > + struct promise_type > + { > + task get_return_object() { return {}; } > + std::suspend_never initial_suspend() { return {}; } > + std::suspend_never final_suspend() noexcept { return {}; } > + void return_void() {} > + void unhandled_exception() {} > + }; > +}; > + > +task resuming_on_new_thread(void) > +{ > + struct awaitable > + { > + bool await_ready() { return false; } > + void await_suspend(std::coroutine_handle<> h) { } > + void await_resume() {} > + }; > + co_await awaitable{}; > +}