public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [committed] libstdc++: Define __cpp_lib_constexpr_string macro
Date: Fri, 30 Apr 2021 22:27:46 +0100	[thread overview]
Message-ID: <20210430212746.GD3008@redhat.com> (raw)
In-Reply-To: <YIl7wk1+dwQrI2ru@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]

On 28/04/21 16:14 +0100, Jonathan Wakely wrote:
>As noted in r11-1339-gb6ab9ecd550227684643b41e9e33a4d3466724d8 we define
>a non-standard __cpp_lib_constexpr_char_traits feature test macro to
>indicate support for P0426R1 and P1032R1. At some point last year the
>__cpp_lib_constexpr_string macro was retconned to indicate support for
>those papers. This adds the new macro (which we didn't previously
>define, because it referred to P0980R1 "Making std::string constexpr"
>which we don't support).
>
>libstdc++-v3/ChangeLog:
>
>	* include/bits/basic_string.h (__cpp_lib_constexpr_string): Define.
>	* include/std/version (__cpp_lib_constexpr_string): Define.
>	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
>	Check for __cpp_lib_constexpr_string.
>	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
>	Likewise.
>	* testsuite/21_strings/char_traits/requirements/version.cc: New test.

I messed up the __cpp_lib_constexpr_string macro by copy&pasting from
the __cpp_lib_constexpr_char_traits one, which is defined inside a
#ifdef __cplusplus >= 201702 block. But for __cpp_lib_constexpr_string
it isn't so the #else means that we define it to 201811L for
everything newer *or* older than C++17.

I also noticed that __cpp_lib_semaphore wasn't defined consistently,
as it's failing on AIX.

Fixed on trunk by this patch. Tested x86_64-linux and powerpc-aix.

I'll backport this to the relevant branches too.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1628 bytes --]

commit 3215d4f5b3d08e0087a88df9e155c779927ace1a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Apr 30 20:32:05 2021

    libstdc++: Fix inconsistent feature test macros
    
    The __cpp_lib_constexpr_string and __cpp_lib_semaphore feature test
    macros are not defined consistently in <version> and the relevant header
    for the feature.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/basic_string.h (__cpp_lib_constexpr_string):
            Only define for C++17 and later.
            * include/std/version (__cpp_lib_semaphore): Fix condition
            to match the one in <semaphore>.

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 41d781c698e..fba7c6f3354 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -55,7 +55,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cplusplus == 201703L
 // Support P0426R1 changes to char_traits in C++17.
 # define __cpp_lib_constexpr_string 201611L
-#else
+#elif __cplusplus > 201703L
 // Also support P1032R1 in C++20 (but not P0980R1 yet).
 # define __cpp_lib_constexpr_string 201811L
 #endif
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 09e67a40d0c..ea0e18a3f9d 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -241,7 +241,7 @@
 #if __cpp_lib_concepts
 # define __cpp_lib_ranges 201911L
 #endif
-#if __cpp_lib_atomic_wait
+#if __cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE
 # define __cpp_lib_semaphore 201907L
 #endif
 #define __cpp_lib_shift 201806L

      reply	other threads:[~2021-04-30 21:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 15:14 Jonathan Wakely
2021-04-30 21:27 ` Jonathan Wakely [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=20210430212746.GD3008@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).