1 // RUN: %check_clang_tidy %s google-readability-casting %t -- -- -x c
2 // The testing script always adds .cpp extension to the input file name, so we
3 // need to run clang-tidy directly in order to verify handling of .c files:
4 // RUN: clang-tidy --checks=-*,google-readability-casting %s -- -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
5 // RUN: cp %s %t.main_file.cpp
6 // RUN: clang-tidy --checks=-*,google-readability-casting -header-filter='.*' %t.main_file.cpp -- -I%S -DTEST_INCLUDE -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
7 
8 #ifdef TEST_INCLUDE
9 
10 #undef TEST_INCLUDE
11 #include "google-readability-casting.c"
12 
13 #else
14 
f(const char * cpc)15 void f(const char *cpc) {
16   const char *cpc2 = (const char*)cpc;
17   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting]
18   // CHECK-FIXES: const char *cpc2 = cpc;
19   char *pc = (char*)cpc;
20   typedef const char *Typedef1;
21   (Typedef1)cpc;
22 }
23 
24 #endif
25