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[]) {
6 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
7 int f4[] = {1, 2};
8 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
9 return 0;
10}
11}
12
13int main(int argc, char *argv[]) {
14 int f5[] = {1, 2};
15 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
16
17 auto not_main = [](int argc, char *argv[]) {
18 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
19 int f6[] = {1, 2};
20 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array' instead
21 };
22}
23

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-main.cpp