22 lines · cpp
1// RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t -- \2// RUN: -config='{CheckOptions: { modernize-avoid-c-arrays.AllowStringArrays: true }}'3 4const char name[] = "name";5const char array[] = {'n', 'a', 'm', 'e', '\0'};6// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]7 8void takeCharArray(const char name[]);9// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead [modernize-avoid-c-arrays]10 11template <typename T = const char[10], typename U = char[10], char[10]>12// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]13// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]14// CHECK-MESSAGES: :[[@LINE-3]]:63: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]15void func() {}16 17template <typename T = const char[], typename U = char[], char[]>18// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]19// CHECK-MESSAGES: :[[@LINE-2]]:51: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]20// CHECK-MESSAGES: :[[@LINE-3]]:59: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]21void fun() {}22