From: Jakub Jelinek Date: Mon, 20 Jul 2026 21:32:40 +0000 (+0200) Subject: c++: implement CWG3020 - Missing specification for __has_cpp_attribute(indeterminate... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71a5a83ea92f4cde1ca2b37f3b160353a729f35b;p=thirdparty%2Fgcc.git 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 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 --- diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index c987618c24e..33ccab3a021 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 d3ab7290124..6db7b06a27e 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 1beb50dc4ad..2474e434090 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