public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: [PATCH] libstdc++: Tweak source_location for clang trunk [PR105128]
Date: Sat, 2 Apr 2022 11:31:38 +0200	[thread overview]
Message-ID: <YkgX+mBNpkpfROAW@tucnak> (raw)

Hi!

Apparently clang trunk implemented __builtin_source_location(), but the
using __builtin_ret_type = decltype(__builtin_source_location());
which has been added for it isn't enough, they also need the
std::source_location::__impl class to be defined (but incomplete seems
to be good enough) before the builtin is used.

The following has been tested on godbolt with clang trunk (old version
fails with
error: 'std::source_location::__impl' was not found; it must be defined before '__builtin_source_location' is called
and some follow-up errors), getting back to just void * instead of
__builtin_ret_type and commenting out using doesn't work either and
just struct __impl; before using __builtin_ret_type doesn't work too.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2022-04-02  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/105128
	* include/std/source_location (std::source_location::__impl): Move
	definition before using __builtin_ret_type.

--- libstdc++-v3/include/std/source_location	2022-02-25 10:46:53.275178858 +0100
+++ libstdc++-v3/include/std/source_location	2022-04-01 19:36:02.056236397 +0200
@@ -43,6 +43,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
   private:
     using uint_least32_t = __UINT_LEAST32_TYPE__;
+    struct __impl
+    {
+      const char* _M_file_name;
+      const char* _M_function_name;
+      unsigned _M_line;
+      unsigned _M_column;
+    };
     using __builtin_ret_type = decltype(__builtin_source_location());
 
   public:
@@ -76,14 +83,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return _M_impl ? _M_impl->_M_function_name : ""; }
 
   private:
-    struct __impl
-    {
-      const char* _M_file_name;
-      const char* _M_function_name;
-      unsigned _M_line;
-      unsigned _M_column;
-    };
-
     const __impl* _M_impl = nullptr;
   };
 

	Jakub


             reply	other threads:[~2022-04-02  9:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-02  9:31 Jakub Jelinek [this message]
2022-04-02 10:46 ` Jonathan Wakely

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=YkgX+mBNpkpfROAW@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /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).