From a4d13e54822dddda4a53137c9f5e23770a798a0b Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Mon, 15 May 2023 12:01:07 -0400 Subject: [PATCH] c++: add feature-test macro for auto(x) This adds the feature-test macro for PR0849R8, as per https://github.com/cplusplus/CWG/issues/281. 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. (cherry picked from commit 32b81d897629b6c3bd9e2780831a1c45b38b5ac3) --- 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 4672ae8486a7..c1b86c1fac09 100644 --- a/gcc/c-family/c-cppbuiltin.cc +++ b/gcc/c-family/c-cppbuiltin.cc @@ -1080,6 +1080,7 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_if_consteval=202106L"); cpp_define (pfile, "__cpp_constexpr=202110L"); cpp_define (pfile, "__cpp_multidimensional_subscript=202110L"); + cpp_define (pfile, "__cpp_auto_cast=202110L"); } if (flag_concepts) { diff --git a/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C b/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C index c1f91e78e66c..d8a1acd17df4 100644 --- a/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C +++ b/gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C @@ -557,3 +557,9 @@ #elif __cpp_multidimensional_subscript != 202110 # error "__cpp_multidimensional_subscript != 202110" #endif + +#ifndef __cpp_auto_cast +# error "__cpp_auto_cast" +#elif __cpp_auto_cast != 202110 +# error "__cpp_auto_cast != 202110" +#endif -- 2.47.3