Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / warn-unsafe-buffer-usage-no-fixits.cpp
blob3b06c15bd3912e718d2052a5389ba9b4ddb7fe53
1 // RUN: %clang_cc1 -x c -Wunsafe-buffer-usage \
2 // RUN: -fsafe-buffer-usage-suggestions \
3 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
5 // RUN: %clang_cc1 -x c -std=c89 -Wunsafe-buffer-usage \
6 // RUN: -fsafe-buffer-usage-suggestions \
7 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
8 // RUN: %clang_cc1 -x c -std=gnu89 -Wunsafe-buffer-usage \
9 // RUN: -fsafe-buffer-usage-suggestions \
10 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
11 // RUN: %clang_cc1 -x c -std=iso9899:1990 -Wunsafe-buffer-usage \
12 // RUN: -fsafe-buffer-usage-suggestions \
13 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
15 // RUN: %clang_cc1 -x c -std=c17 -Wunsafe-buffer-usage \
16 // RUN: -fsafe-buffer-usage-suggestions \
17 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
18 // RUN: %clang_cc1 -x c -std=gnu17 -Wunsafe-buffer-usage \
19 // RUN: -fsafe-buffer-usage-suggestions \
20 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
21 // RUN: %clang_cc1 -x c -std=iso9899:2017 -Wunsafe-buffer-usage \
22 // RUN: -fsafe-buffer-usage-suggestions \
23 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
24 // RUN: %clang_cc1 -x c -std=c2x -Wunsafe-buffer-usage \
25 // RUN: -fsafe-buffer-usage-suggestions \
26 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
28 // RUN: %clang_cc1 -x c++ -std=c++98 -Wunsafe-buffer-usage \
29 // RUN: -fsafe-buffer-usage-suggestions \
30 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
31 // RUN: %clang_cc1 -x c++ -std=gnu++98 -Wunsafe-buffer-usage \
32 // RUN: -fsafe-buffer-usage-suggestions \
33 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
34 // RUN: %clang_cc1 -x c++ -std=c++17 -Wunsafe-buffer-usage \
35 // RUN: -fsafe-buffer-usage-suggestions \
36 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
37 // RUN: %clang_cc1 -x c++ -std=gnu++17 -Wunsafe-buffer-usage \
38 // RUN: -fsafe-buffer-usage-suggestions \
39 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
41 // RUN: %clang_cc1 -x objective-c++ -std=c++98 -Wunsafe-buffer-usage \
42 // RUN: -fsafe-buffer-usage-suggestions \
43 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
44 // RUN: %clang_cc1 -x objective-c++ -std=gnu++98 -Wunsafe-buffer-usage \
45 // RUN: -fsafe-buffer-usage-suggestions \
46 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
47 // RUN: %clang_cc1 -x objective-c++ -std=c++17 -Wunsafe-buffer-usage \
48 // RUN: -fsafe-buffer-usage-suggestions \
49 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
50 // RUN: %clang_cc1 -x objective-c++ -std=gnu++17 -Wunsafe-buffer-usage \
51 // RUN: -fsafe-buffer-usage-suggestions \
52 // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
54 // CHECK-NOT: fix-it:
56 typedef int * Int_ptr_t;
57 typedef int Int_t;
59 void local_array_subscript_simple() {
60 int tmp;
61 int *p;
62 const int *q;
63 tmp = p[5];
64 tmp = q[5];
66 Int_ptr_t x;
67 Int_ptr_t y;
68 Int_t * z;
69 Int_t * w;
71 tmp = x[5];
72 tmp = y[5];
73 tmp = z[5];
74 tmp = w[5];
77 void local_ptr_to_array() {
78 int tmp;
79 int n = 10;
80 int a[10];
81 int b[n];
82 int *p = a;
83 int *q = b;
84 tmp = p[5];
85 tmp = q[5];
88 void local_ptr_addrof_init() {
89 int var;
90 int * q = &var;
91 var = q[5];
94 void decl_without_init() {
95 int tmp;
96 int * p;
97 Int_ptr_t q;
98 tmp = p[5];
99 tmp = q[5];
102 void explict_cast() {
103 int tmp;
104 int * p;
105 tmp = p[5];
107 int a;
108 char * q = (char *)&a;
109 tmp = (int) q[5];
111 void * r = &a;
112 char * s = (char *) r;
113 tmp = (int) s[5];