Skip to content

Commit 979c4e9

Browse files
[-Wunsafe-buffer-usage][NFC] Reintroduce lost test cases (#82060)
We likely accidentally removed these as part of conflict resolution.
1 parent 0e6a48c commit 979c4e9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,36 @@ void local_variable_qualifiers_specifiers() {
5757
int tmp;
5858
tmp = p[5];
5959
tmp = q[5];
60+
61+
[[deprecated]] const int * x = a;
62+
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:29}:"std::span<int const>"
63+
const int * y [[deprecated]];
64+
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:14}:"std::span<int const>"
65+
tmp = x[5];
66+
tmp = y[5];
6067
}
6168

69+
void local_variable_unsupported_specifiers() {
70+
int a[10];
71+
const int * p [[deprecated]] = a; // not supported because the attribute overlaps the source range of the declaration
72+
// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
73+
74+
static const int * q = a; // storage specifier not supported yet
75+
// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
76+
77+
extern int * x; // storage specifier not supported yet
78+
// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
79+
80+
constexpr int * y = 0; // `constexpr` specifier not supported yet
81+
// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
82+
83+
int tmp;
84+
85+
tmp = p[5];
86+
tmp = q[5];
87+
tmp = x[5];
88+
tmp = y[5];
89+
}
6290

6391
void local_array_subscript_variable_extent() {
6492
int n = 10;

0 commit comments

Comments
 (0)