summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp
blob: 8b9feb43d93c1e952fc878421ad076f2b37fc976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: clang-tidy -checks=-*,google-readability-casting %s -- | FileCheck %s

// CHECK-NOT: warning:

bool g() { return false; }

void f(int a, double b) {
  int b1 = (int)b;
  // CHECK: :[[@LINE-1]]:12: warning: C-style casts are discouraged. Use static_cast{{.*}}

  // CHECK-NOT: warning:
  int b2 = int(b);
  int b3 = static_cast<double>(b);
  int b4 = b;
  double aa = a;
  (void)b2;
  return (void)g();
}

// CHECK-NOT: warning:
enum E { E1 = 1 };
template <E e>
struct A { static const E ee = e; };
struct B : public A<E1> {};
OpenPOWER on IntegriCloud