public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Cc: jason@redhat.com
Subject: Re: [PATCH] c++: modules and std::source_location::current() def arg [PR100881]
Date: Thu, 8 Dec 2022 07:41:15 -0500	[thread overview]
Message-ID: <6658e6b7-28af-aafa-a45e-970805474667@acm.org> (raw)
In-Reply-To: <20221207215028.1851790-1-ppalka@redhat.com>

On 12/7/22 16:50, Patrick Palka wrote:
> We currently declare __builtin_source_location with a const void* return
> type instead of the true type (const std::source_location::__impl*), and
> later when folding this builtin we just obtain the true type via name
> lookup.
> 
> But the below testcase demonstrates this name lookup approach seems to
> interact poorly with modules, since we may import an entity that uses
> std::source_location::current() in a default argument (or DMI) without
> also importing <source_location>, and thus the name lookup will fail
> when folding the builtin at the call site unless we also import
> <source_location>.
> 
> This patch fixes by instead initially declaring __builtin_source_location
> with an auto return type and updating it appropriately upon its first use.
> Thus when folding calls to this builtin we can fish out the true return
> type through the type of the CALL_EXPR and avoid needing to do name
> lookup.

That's a clever approach!  LGTM

nathan

-- 
Nathan Sidwell


      reply	other threads:[~2022-12-08 12:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 21:50 Patrick Palka
2022-12-08 12:41 ` Nathan Sidwell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6658e6b7-28af-aafa-a45e-970805474667@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).