public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: add feature-test macro for auto(x)
@ 2023-05-15 15:24 Patrick Palka
  2023-05-15 15:41 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Palka @ 2023-05-15 15:24 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, Patrick Palka

This adds the feature-test macro for PR0849R8, as per
https://github.com/cplusplus/CWG/issues/281.

Tested on x86_64-pc-linux-gnu, does this look OK for trunk/13?

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_auto_cast
	for C++23.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_auto_cast.
---
 gcc/c-family/c-cppbuiltin.cc            | 1 +
 gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 98f5aef2af9..5d64625fcd7 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1074,6 +1074,7 @@ c_cpp_builtins (cpp_reader *pfile)
 	  /* Set feature test macros for C++23.  */
 	  cpp_define (pfile, "__cpp_size_t_suffix=202011L");
 	  cpp_define (pfile, "__cpp_if_consteval=202106L");
+	  cpp_define (pfile, "__cpp_auto_cast=202110L");
 	  cpp_define (pfile, "__cpp_constexpr=202211L");
 	  cpp_define (pfile, "__cpp_multidimensional_subscript=202211L");
 	  cpp_define (pfile, "__cpp_named_character_escapes=202207L");
diff --git a/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C b/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
index 6f4f6bcaad0..9e29b01adc1 100644
--- a/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
+++ b/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
@@ -578,6 +578,12 @@
 #  error "__cpp_implicit_move != 202207"
 #endif
 
+#ifndef __cpp_auto_cast
+#  error "__cpp_auto_cast"
+#elif __cpp_auto_cast != 202110
+#  error "__cpp_auto_cast != 202110"
+#endif
+
 //  C++23 attributes:
 
 #ifdef __has_cpp_attribute
-- 
2.40.1.552.g91428f078b


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] c++: add feature-test macro for auto(x)
  2023-05-15 15:24 [PATCH] c++: add feature-test macro for auto(x) Patrick Palka
@ 2023-05-15 15:41 ` Jason Merrill
  2023-05-15 15:43   ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2023-05-15 15:41 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches

On 5/15/23 11:24, Patrick Palka wrote:
> This adds the feature-test macro for PR0849R8, as per
> https://github.com/cplusplus/CWG/issues/281.
> 
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk/13?

OK.

> gcc/c-family/ChangeLog:
> 
> 	* c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_auto_cast
> 	for C++23.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_auto_cast.
> ---
>   gcc/c-family/c-cppbuiltin.cc            | 1 +
>   gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C | 6 ++++++
>   2 files changed, 7 insertions(+)
> 
> diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
> index 98f5aef2af9..5d64625fcd7 100644
> --- a/gcc/c-family/c-cppbuiltin.cc
> +++ b/gcc/c-family/c-cppbuiltin.cc
> @@ -1074,6 +1074,7 @@ c_cpp_builtins (cpp_reader *pfile)
>   	  /* Set feature test macros for C++23.  */
>   	  cpp_define (pfile, "__cpp_size_t_suffix=202011L");
>   	  cpp_define (pfile, "__cpp_if_consteval=202106L");
> +	  cpp_define (pfile, "__cpp_auto_cast=202110L");
>   	  cpp_define (pfile, "__cpp_constexpr=202211L");
>   	  cpp_define (pfile, "__cpp_multidimensional_subscript=202211L");
>   	  cpp_define (pfile, "__cpp_named_character_escapes=202207L");
> diff --git a/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C b/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
> index 6f4f6bcaad0..9e29b01adc1 100644
> --- a/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
> +++ b/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
> @@ -578,6 +578,12 @@
>   #  error "__cpp_implicit_move != 202207"
>   #endif
>   
> +#ifndef __cpp_auto_cast
> +#  error "__cpp_auto_cast"
> +#elif __cpp_auto_cast != 202110
> +#  error "__cpp_auto_cast != 202110"
> +#endif
> +
>   //  C++23 attributes:
>   
>   #ifdef __has_cpp_attribute


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] c++: add feature-test macro for auto(x)
  2023-05-15 15:41 ` Jason Merrill
@ 2023-05-15 15:43   ` Jakub Jelinek
  2023-05-15 15:48     ` Patrick Palka
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2023-05-15 15:43 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Patrick Palka, gcc-patches

On Mon, May 15, 2023 at 11:41:46AM -0400, Jason Merrill via Gcc-patches wrote:
> On 5/15/23 11:24, Patrick Palka wrote:
> > This adds the feature-test macro for PR0849R8, as per
> > https://github.com/cplusplus/CWG/issues/281.
> > 
> > Tested on x86_64-pc-linux-gnu, does this look OK for trunk/13?
> 
> OK.

https://gcc.gnu.org/projects/cxx-status.html#cxx23 lists it already in 12,
shouldn't that go to 12 branch as well?
> 
> > gcc/c-family/ChangeLog:
> > 
> > 	* c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_auto_cast
> > 	for C++23.
> > 
> > gcc/testsuite/ChangeLog:
> > 
> > 	* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_auto_cast.

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] c++: add feature-test macro for auto(x)
  2023-05-15 15:43   ` Jakub Jelinek
@ 2023-05-15 15:48     ` Patrick Palka
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick Palka @ 2023-05-15 15:48 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jason Merrill, gcc-patches

On Mon, May 15, 2023 at 11:43 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, May 15, 2023 at 11:41:46AM -0400, Jason Merrill via Gcc-patches wrote:
> > On 5/15/23 11:24, Patrick Palka wrote:
> > > This adds the feature-test macro for PR0849R8, as per
> > > https://github.com/cplusplus/CWG/issues/281.
> > >
> > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk/13?
> >
> > OK.
>
> https://gcc.gnu.org/projects/cxx-status.html#cxx23 lists it already in 12,
> shouldn't that go to 12 branch as well?

D'oh, I misremembered when Marek implemented this!  I can backport it
to 12 as well.

> >
> > > gcc/c-family/ChangeLog:
> > >
> > >     * c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_auto_cast
> > >     for C++23.
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > >     * g++.dg/cpp23/feat-cxx2b.C: Test __cpp_auto_cast.
>
>         Jakub
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-15 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15 15:24 [PATCH] c++: add feature-test macro for auto(x) Patrick Palka
2023-05-15 15:41 ` Jason Merrill
2023-05-15 15:43   ` Jakub Jelinek
2023-05-15 15:48     ` Patrick Palka

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).