From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by sourceware.org (Postfix) with ESMTPS id 3A152385C6CF for ; Mon, 29 Jul 2024 23:02:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A152385C6CF Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=aarsen.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=aarsen.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3A152385C6CF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=80.241.56.161 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722294178; cv=none; b=g8VCh0eMlq89bKl2+n6jeAW4Amtos+ufusX2JkGx6vCNIFmImD5/VnV4np3rEfHvHYNbN1fwflZ6UGZ4jPSUJ8y/oL5syO5h/NEbTUiIxJqcouv++oGpIvHP92MbS3gDTgwzbbPtvKQdW+/+6GgLRYIVs37q1TFKz0H3rd3bHfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722294178; c=relaxed/simple; bh=PjZVwzu+8uEKTx0E2PV2NQbqf7tyqFsw4pmL3khIE54=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iHy/CUe6iQuW1w7TdCN8lzu8vSlSk+EcdX6eje29XIFP7ap1EsXHn0HAq1QIkJkVOQGBGTsQ/kDl1zqDk0Q0NABDZAcSi3NPaeWYnbUC8dwQMduMEQPGU4f+pC9MDG9kM0LOYjClmTZ6GDFl9X6ji9TWKSKs3ih2e/pexHa/KtI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4WXv5m0VSpz9srN; Tue, 30 Jul 2024 01:02:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1722294172; 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: in-reply-to:in-reply-to:references:references; bh=xaMqfok2wwGCWCgyl/pa8d0hHbbwikT5zOu6ui6HJiI=; b=pWPV8whubm+z3G2VfrHddNcrjBcXkAoFyw0EqmSrw1pWwNBtR3MDknByRbDXTchGEo1mCj gtAASL+89AENOUTWE+XyRIOwrX/C7MxhgKHddWbL3Dru7kCPkk8JpH23fTNgzzcSji2L3W g2DQxdq+yLvm8z7S0sLS0mrRt6JuL7BOTKiLnDD8RyahtVNKo1pzHOMOjpZIei6rTZ0neZ WUNyQBklp+uLsAuJpe6hB0BElREjbJAHd/EUbMNeiSAHNPGKKNtxqLjCrRvgaN+AeRgBKx vae74t1B2prz62BkGJkFJPR2G1xZ2xJMpoKm8iVavYuvCF9jdP+3dFin8YVQmA== From: =?utf-8?Q?Arsen_Arsenovi=C4=87?= To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Iain Sandoe Subject: Re: [PATCH] c++: make BUILTIN_SOURCE_LOCATION follow DECL_RAMP_FN In-Reply-To: <991666db-1b0b-482e-8bb6-ef6bfffbd854@redhat.com> (Jason Merrill's message of "Mon, 29 Jul 2024 15:37:34 -0400") References: <20240729122211.779156-1-arsen@aarsen.me> <991666db-1b0b-482e-8bb6-ef6bfffbd854@redhat.com> Date: Tue, 30 Jul 2024 01:02:50 +0200 Message-ID: <86frrrvm1x.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Rspamd-Queue-Id: 4WXv5m0VSpz9srN X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_INFOUSMEBIZ,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,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: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jason Merrill writes: > I don't know what all-caps BUILTIN_SOURCE_LOCATION refers to specifically= (it > doesn't match CP_BUILT_IN_SOURCE_LOCATION, for instance); let's just refe= r to > source_location. ACK - will reword. > On 7/29/24 8:20 AM, Arsen Arsenovi=C4=87 wrote: >> This fixes the value of current_function in compiler generated coroutine >> code. >> PR c++/110855 - std::source_location doesn't work with C++20 coroutine >> gcc/cp/ChangeLog: >> PR c++/110855 >> * cp-gimplify.cc (fold_builtin_source_location): Use the name of >> the DECL_RAMP_FN of the current function if present. >> gcc/testsuite/ChangeLog: >> PR c++/110855 >> * g++.dg/coroutines/pr110855.C: New test. >> --- >> Tested on x86_64-pc-linux-gnu. >> OK for trunk? >> TIA, have a lovely day. > > Again, best to put stuff like this that doesn't go in the commit message = first, > followed by scissors (-- 8< --), then the commit message. Ah, I see what you mean now. Sorry, will use that feature in the future. > The patch is OK. Thanks. >> gcc/cp/cp-gimplify.cc | 9 +++- >> gcc/testsuite/g++.dg/coroutines/pr110855.C | 61 ++++++++++++++++++++++ >> 2 files changed, 69 insertions(+), 1 deletion(-) >> create mode 100644 gcc/testsuite/g++.dg/coroutines/pr110855.C >> diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc >> index e6629dea5fdc..651751312fbe 100644 >> --- a/gcc/cp/cp-gimplify.cc >> +++ b/gcc/cp/cp-gimplify.cc >> @@ -3929,7 +3929,14 @@ fold_builtin_source_location (const_tree t) >> const char *name =3D ""; >> if (current_function_decl) >> - name =3D cxx_printable_name (current_function_decl, 2); >> + { >> + /* If this is a coroutine, we should get the name of the user >> + function rather than the actor we generate. */ >> + if (tree ramp =3D DECL_RAMP_FN (current_function_decl)) >> + name =3D cxx_printable_name (ramp, 2); >> + else >> + name =3D cxx_printable_name (current_function_decl, 2); >> + } >> val =3D build_string_literal (name); >> } >> diff --git a/gcc/testsuite/g++.dg/coroutines/pr110855.C b/gcc/testsuite/= g++.dg/coroutines/pr110855.C >> new file mode 100644 >> index 000000000000..6b5c0147ec83 >> --- /dev/null >> +++ b/gcc/testsuite/g++.dg/coroutines/pr110855.C >> @@ -0,0 +1,61 @@ >> +// { dg-do run } >> +// { dg-output {^} } >> +// { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} } >> +// { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} } >> +// { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} } >> +// { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} } >> +// { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} } >> +// { dg-output {$} } >> +// https://gcc.gnu.org/PR110855 >> +#include >> +#include >> + >> +struct ReturnObject { >> + struct promise_type { >> + auto >> + initial_suspend(const std::source_location location =3D >> + std::source_location::current()) { >> + __builtin_puts (location.function_name ()); >> + return std::suspend_never{}; >> + } >> + auto >> + final_suspend(const std::source_location location =3D >> + std::source_location::current()) noexcept { >> + __builtin_puts (location.function_name ()); >> + return std::suspend_never{}; >> + } >> + auto >> + get_return_object(const std::source_location location =3D >> + std::source_location::current()) { >> + __builtin_puts (location.function_name ()); >> + return ReturnObject{std::coroutine_handle::from_pro= mise(*this)}; >> + } >> + auto >> + unhandled_exception() { } >> + auto return_void(const std::source_location location =3D >> + std::source_location::current()) { >> + __builtin_puts (location.function_name ()); >> + } >> + }; >> + std::coroutine_handle<> handle; >> +}; >> + >> +struct awaitable : std::suspend_never >> +{ >> + void await_resume(const std::source_location location =3D >> + std::source_location::current()) >> + { >> + __builtin_puts (location.function_name ()); >> + } >> +}; >> + >> +ReturnObject >> +bar(int, char, bool) { >> + co_await awaitable{}; >> + co_return; >> +} >> + >> +int >> +main() { >> + bar(1, 'a', false); >> +} =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZqgfml8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTJ7gBAM8xWfiBxqEI+er1RuVymmtR31I8vI63P0Mx TfXZPX9DAQCUJQ/yi0+2Kll9SGEsIqxmcTBXm6d9m9bkQ0fbcEAeBg== =OUW/ -----END PGP SIGNATURE----- --=-=-=--