Manuel Klimek | 8f9e444 | 2015-10-22 14:54:50 +0000 | [diff] [blame] | 1 | // RUN: %check_clang_tidy %s google-readability-casting %t -- -- -x c |
Alexander Kornienko | 19bbeaf | 2015-05-21 14:08:56 +0000 | [diff] [blame] | 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}}:' |
Alexander Kornienko | 2b56649 | 2015-05-26 10:47:48 +0000 | [diff] [blame] | 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}}:' |
Alexander Kornienko | 02bd018 | 2014-09-21 23:39:28 +0000 | [diff] [blame] | 7 | |
Alexander Kornienko | 2b56649 | 2015-05-26 10:47:48 +0000 | [diff] [blame] | 8 | #ifdef TEST_INCLUDE |
| 9 | |
| 10 | #undef TEST_INCLUDE |
| 11 | #include "google-readability-casting.c" |
| 12 | |
| 13 | #else |
| 14 | |
Alexander Kornienko | 02bd018 | 2014-09-21 23:39:28 +0000 | [diff] [blame] | 15 | void f(const char *cpc) { |
| 16 | const char *cpc2 = (const char*)cpc; |
Alexander Kornienko | 78070fb | 2015-01-29 15:17:13 +0000 | [diff] [blame] | 17 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting] |
Alexander Kornienko | 02bd018 | 2014-09-21 23:39:28 +0000 | [diff] [blame] | 18 | // CHECK-FIXES: const char *cpc2 = cpc; |
| 19 | char *pc = (char*)cpc; |
Alexander Kornienko | db04ccc | 2017-03-03 08:18:49 +0000 | [diff] [blame] | 20 | typedef const char *Typedef1; |
| 21 | (Typedef1)cpc; |
Alexander Kornienko | 02bd018 | 2014-09-21 23:39:28 +0000 | [diff] [blame] | 22 | } |
Alexander Kornienko | 2b56649 | 2015-05-26 10:47:48 +0000 | [diff] [blame] | 23 | |
| 24 | #endif |