2015-10-22 22:54:50 +08:00
|
|
|
// RUN: %check_clang_tidy %s google-readability-casting %t -- -- -x c
|
2015-05-21 22:08:56 +08:00
|
|
|
// The testing script always adds .cpp extension to the input file name, so we
|
|
|
|
// need to run clang-tidy directly in order to verify handling of .c files:
|
|
|
|
// RUN: clang-tidy --checks=-*,google-readability-casting %s -- -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
|
2015-05-26 18:47:48 +08:00
|
|
|
// RUN: cp %s %t.main_file.cpp
|
|
|
|
// 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}}:'
|
2014-09-22 07:39:28 +08:00
|
|
|
|
2015-05-26 18:47:48 +08:00
|
|
|
#ifdef TEST_INCLUDE
|
|
|
|
|
|
|
|
#undef TEST_INCLUDE
|
|
|
|
#include "google-readability-casting.c"
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2014-09-22 07:39:28 +08:00
|
|
|
void f(const char *cpc) {
|
|
|
|
const char *cpc2 = (const char*)cpc;
|
2015-01-29 23:17:13 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting]
|
2014-09-22 07:39:28 +08:00
|
|
|
// CHECK-FIXES: const char *cpc2 = cpc;
|
|
|
|
char *pc = (char*)cpc;
|
2017-03-03 16:18:49 +08:00
|
|
|
typedef const char *Typedef1;
|
|
|
|
(Typedef1)cpc;
|
2014-09-22 07:39:28 +08:00
|
|
|
}
|
2015-05-26 18:47:48 +08:00
|
|
|
|
|
|
|
#endif
|