| // RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" -- |
| void assign(int a, int b) { |
| // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast] |
| // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' |
| l = static_cast<long>(a * b); |
| // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' |
| void compare(int a, int b, long c) { |
| // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' |
| // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long' |
| void init(unsigned int n) { |
| long l2 = (long)(n << 8); |
| // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: either cast from 'unsigned int' to 'long' |
| void call(unsigned int n) { |
| // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: either cast from 'unsigned int' to 'long' |
| // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long' |
| // Shall not generate an assert. https://bugs.llvm.org/show_bug.cgi?id=33660 |
| template <class> class A { |
| static char *m_fn1() { char p = (Type)(&p - m_fn1()); } |