[clang] [-Wunsafe-buffer-usage][NFC] Reintroduce lost test cases (PR #82060)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 16 14:50:38 PST 2024


https://github.com/jkorous-apple created https://github.com/llvm/llvm-project/pull/82060

We likely accidentally removed these as part of conflict resolution.

>From 731fe4d78542fa72738a1f16a3ecf9fbd5c6e4d0 Mon Sep 17 00:00:00 2001
From: Jan Korous <jkorous at apple.com>
Date: Fri, 16 Feb 2024 14:49:56 -0800
Subject: [PATCH] [-Wunsafe-buffer-usage][NFC] Reintroduce lost test cases

We likely accidentally removed these as part of conflict resolution.
---
 ...afe-buffer-usage-fixits-local-var-span.cpp | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
index 68b2cef1919379..292e89cb00c9e4 100644
--- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -57,8 +57,36 @@ void local_variable_qualifiers_specifiers() {
   int tmp;
   tmp = p[5];
   tmp = q[5];
+
+  [[deprecated]] const int * x = a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:29}:"std::span<int const>"
+  const int * y [[deprecated]];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:14}:"std::span<int const>"
+  tmp = x[5];
+  tmp = y[5];
 }
 
+void local_variable_unsupported_specifiers() {
+  int a[10];
+  const int * p [[deprecated]] = a; //  not supported because the attribute overlaps the source range of the declaration
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  static const int * q = a; //  storage specifier not supported yet
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  extern int * x; //  storage specifier not supported yet
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  constexpr int * y = 0; //  `constexpr` specifier not supported yet
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+  int tmp;
+
+  tmp = p[5];
+  tmp = q[5];
+  tmp = x[5];
+  tmp = y[5];
+}
 
 void local_array_subscript_variable_extent() {
   int n = 10;



More information about the cfe-commits mailing list