================
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify=cxx23 %s
+
+// Test for C++26 [[indeterminate]] attribute (P2795R5)
+
+// In C++23, the attribute is unknown and ignored
+void test_cxx23() {
+ [[indeterminate]] int x; // cxx23-warning {{'indeterminate' attribute
ignored}}
+}
+
+#if __cplusplus >= 202400L
+
+// local variable with automatic storage duration
+void test_local_var() {
+ [[indeterminate]] int x; // OK
+ [[indeterminate]] int arr[10]; // OK
+ [[indeterminate]] int a, b, c; // OK - multiple declarators
+}
+
+// function parameter
+void test_param([[indeterminate]] int x); // OK
+
+// static storage duration
+// expected-warning@+1 {{'indeterminate' attribute only applies to local
variables or function parameters}}
+[[indeterminate]] int global_var;
+
+void test_static() {
+ // expected-warning@+1 {{'indeterminate' attribute only applies to local
variables or function parameters}}
+ [[indeterminate]] static int x;
+ // expected-warning@+1 {{'indeterminate' attribute only applies to local
variables or function parameters}}
+ [[indeterminate]] thread_local int y;
+}
+
+// attribute on class-type local variable
+struct S {
+ int x;
+ S() {}
+};
+
+void test_class_type() {
+ [[indeterminate]] S s; // OK - member x has indeterminate value
+}
+
+// constexpr context should error on reading indeterminate value
----------------
yronglin wrote:
Added
https://github.com/llvm/llvm-project/pull/177614
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits