[clang] 6b6c7e4 - [clang][Interp][NFC] Test out-of-bounds access on vectors

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 01:42:56 PDT 2024


Author: Timm Bäder
Date: 2024-04-22T10:35:45+02:00
New Revision: 6b6c7e46cc1e97b678e969bad78825dd02c11ff9

URL: https://github.com/llvm/llvm-project/commit/6b6c7e46cc1e97b678e969bad78825dd02c11ff9
DIFF: https://github.com/llvm/llvm-project/commit/6b6c7e46cc1e97b678e969bad78825dd02c11ff9.diff

LOG: [clang][Interp][NFC] Test out-of-bounds access on vectors

Added: 
    

Modified: 
    clang/test/AST/Interp/vectors.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/AST/Interp/vectors.cpp b/clang/test/AST/Interp/vectors.cpp
index 5c4694f122d812..cb8bcd4fdda768 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -8,6 +8,13 @@ static_assert(A[1] == 2, ""); // ref-error {{not an integral constant expression
 static_assert(A[2] == 3, ""); // ref-error {{not an integral constant expression}}
 static_assert(A[3] == 4, ""); // ref-error {{not an integral constant expression}}
 
+
+/// FIXME: It would be nice if the note said 'vector' instead of 'array'.
+static_assert(A[12] == 4, ""); // ref-error {{not an integral constant expression}} \
+                               // expected-error {{not an integral constant expression}} \
+                               // expected-note {{cannot refer to element 12 of array of 4 elements in a constant expression}}
+
+
 /// VectorSplat casts
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 constexpr float4 vec4_0 = (float4)0.5f;


        


More information about the cfe-commits mailing list