1// RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
2
3namespace X {
4// Not main.
5int main(int argc, char *argv[], char *argw[]) {
6 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
7 // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
8 int f4[] = {1, 2};
9 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
10 return 0;
11}
12}
13
14int main(int argc, char *argv[], char *argw[]) {
15 int f5[] = {1, 2};
16 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
17
18 auto main = [](int argc, char *argv[], char *argw[]) {
19 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
20 // CHECK-MESSAGES: :[[@LINE-2]]:42: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
21 int f6[] = {1, 2};
22 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array' instead
23 };
24}
25

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp