[clang] [-Wunsafe-buffer-usage] Suppress warning for multi-dimensional constant arrays (PR #118249)

Malavika Samak via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 03:39:16 PST 2024


================
@@ -52,3 +52,37 @@ void constant_id_string(unsigned idx) {
   unsafe_char = ""[1]; //expected-warning{{unsafe buffer access}} 
   unsafe_char = ""[idx]; //expected-warning{{unsafe buffer access}}
 }
+
+typedef float Float4x4[4][4];
+
+// expected-warning at +1 {{'matrix' is an unsafe buffer that does not perform bounds checks}}
+float two_dimension_array(Float4x4& matrix) {
+  // expected-note at +1{{used in buffer access here}}
+  float a = matrix[0][4];
----------------
malavikasamak wrote:

Done

https://github.com/llvm/llvm-project/pull/118249


More information about the cfe-commits mailing list