On 7/20/26 3:38 AM, Jakub Jelinek wrote:
Hi!
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.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Shall we backport this to 16.2 (obviously without the feat-cxx29.C hunk)?
OK, yes.
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.
--- gcc/c-family/c-lex.cc.jj 2026-07-15 09:21:31.677668411 +0200
+++ gcc/c-family/c-lex.cc 2026-07-18 00:37:16.904290859 +0200
@@ -449,6 +449,8 @@ c_common_has_attribute (cpp_reader *pfil
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
--- gcc/testsuite/g++.dg/cpp26/feat-cxx26.C.jj 2026-06-12 16:55:01.609239303
+0200
+++ gcc/testsuite/g++.dg/cpp26/feat-cxx26.C 2026-07-18 00:39:10.538292243
+0200
@@ -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
--- gcc/testsuite/g++.dg/cpp29/feat-cxx29.C.jj 2026-07-17 19:08:20.834454841
+0200
+++ gcc/testsuite/g++.dg/cpp29/feat-cxx29.C 2026-07-18 00:40:09.358178524
+0200
@@ -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
Jakub