https://gcc.gnu.org/g:71a5a83ea92f4cde1ca2b37f3b160353a729f35b
commit r17-2575-g71a5a83ea92f4cde1ca2b37f3b160353a729f35b Author: Jakub Jelinek <[email protected]> Date: Mon Jul 20 23:32:40 2026 +0200 c++: implement CWG3020 - Missing specification for __has_cpp_attribute(indeterminate) [PR126309] The paper which introduced indeterminate attribute has not added a value for __has_cpp_attribute, so I've missed it and didn't add it to c_common_has_attribute. Later CWG issue fixed this up. 2026-07-20 Jakub Jelinek <[email protected]> PR c++/126309 * c-lex.cc: Implement CWG3020 - Missing specification for __has_cpp_attribute(indeterminate). (c_common_has_attribute): Handle __has_cpp_attribute (indeterminate). * g++.dg/cpp26/feat-cxx26.C: Test __has_cpp_attribute (indeterminate). * g++.dg/cpp29/feat-cxx29.C: Likewise. Reviewed-by: Jason Merrill <[email protected]> Diff: --- gcc/c-family/c-lex.cc | 2 ++ gcc/testsuite/g++.dg/cpp26/feat-cxx26.C | 12 ++++++++++++ gcc/testsuite/g++.dg/cpp29/feat-cxx29.C | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index c987618c24e7..33ccab3a0214 100644 --- a/gcc/c-family/c-lex.cc +++ b/gcc/c-family/c-lex.cc @@ -449,6 +449,8 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) result = 201907; else if (is_attribute_p ("assume", attr_name)) result = 202207; + else if (is_attribute_p ("indeterminate", attr_name)) + result = 202403; else if (is_attribute_p ("init_priority", attr_name)) { /* The (non-standard) init_priority attribute is always diff --git a/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C b/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C index d3ab72901240..6db7b06a27e9 100644 --- a/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C +++ b/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C @@ -658,3 +658,15 @@ #elif __cpp_trivial_union != 202502 # error "__cpp_trivial_union != 202502" #endif + +// C++26 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(indeterminate) +# error "__has_cpp_attribute(indeterminate)" +# elif __has_cpp_attribute(indeterminate) != 202403 +# error "__has_cpp_attribute(indeterminate) != 202403" +# endif +#else +# error "__has_cpp_attribute" +#endif diff --git a/gcc/testsuite/g++.dg/cpp29/feat-cxx29.C b/gcc/testsuite/g++.dg/cpp29/feat-cxx29.C index 1beb50dc4ad4..2474e4340900 100644 --- a/gcc/testsuite/g++.dg/cpp29/feat-cxx29.C +++ b/gcc/testsuite/g++.dg/cpp29/feat-cxx29.C @@ -658,3 +658,15 @@ #elif __cpp_trivial_union != 202502 # error "__cpp_trivial_union != 202502" #endif + +// C++26 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(indeterminate) +# error "__has_cpp_attribute(indeterminate)" +# elif __has_cpp_attribute(indeterminate) != 202403 +# error "__has_cpp_attribute(indeterminate) != 202403" +# endif +#else +# error "__has_cpp_attribute" +#endif
