1 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage \
2 // RUN: -fsafe-buffer-usage-suggestions \
3 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
5 int ptr(unsigned idx
) {
6 int * ptr
= new int[1];
7 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:8}:"std::span<int>"
13 int ptr_to_const(unsigned idx
) {
14 const int * ptr
= new int[1];
15 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:14}:"std::span<int const>"
21 int const_ptr(unsigned idx
) {
22 int * const ptr
= new int[1];
23 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:8}:"std::span<int>"
29 int const_ptr_to_const(unsigned idx
) {
30 const int * const ptr
= new int[1];
31 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:14}:"std::span<int const>"
37 int ptr_to_const_volatile(unsigned idx
) {
38 const volatile int * ptr
= new int[1];
39 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:23}:"std::span<int const volatile>"
45 int const_volatile_ptr(unsigned idx
) {
46 int * const volatile ptr
= new int[1];
47 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:8}:"std::span<int>"
53 int const_volatile_ptr_to_const_volatile(unsigned idx
) {
54 const volatile int * const volatile ptr
= new int[1];
55 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:23}:"std::span<int const volatile>"
61 typedef const int * my_const_int_star
;
62 int typedef_ptr_to_const(unsigned idx
) {
63 my_const_int_star ptr
= new int[1];
64 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
70 typedef int * const my_int_star_const
;
71 int typedef_const_ptr(unsigned idx
) {
72 my_int_star_const ptr
= new int[1];
73 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
79 typedef const int * const my_const_int_star_const
;
80 int typedef_const_ptr_to_const(unsigned idx
) {
81 my_const_int_star_const ptr
= new int[1];
82 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
88 int ptr_to_decltype(unsigned idx
) {
90 decltype(a
) * ptr
= new int[1];
91 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:16}:"std::span<decltype(a)>"
96 int decltype_ptr(unsigned idx
) {
98 decltype(p
) ptr
= new int[1];
99 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]: