blob: d7ea893c21562bc2184c8eb2d624b1b71ac4f156 [file] [log] [blame]
Aaron Ballmancf6cefd2016-06-07 17:22:47 +00001// RUN: %check_clang_tidy %s misc-misplaced-const %t
2
3typedef int plain_i;
4typedef int *ip;
5typedef const int *cip;
6
7void func() {
8 if (const int *i = 0)
9 ;
10 if (const plain_i *i = 0)
11 ;
12 if (const cip i = 0)
13 ;
14
15 // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'i' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
16 if (const ip i = 0)
17 ;
18}
19
20template <typename Ty>
21struct S {
22 const Ty *i;
23 const Ty &i2;
24};
25
26template struct S<int>;
27template struct S<ip>; // ok
28template struct S<cip>;
Aaron Ballman4c4bdba2016-06-07 17:32:07 +000029
30template <typename Ty>
31struct U {
32 const Ty *i;
33 const Ty &i2;
34};
35
36template struct U<int *>; // ok
Aaron Ballmancf6cefd2016-06-07 17:22:47 +000037
38struct T {
39 typedef void (T::*PMF)();
40
41 void f() {
42 const PMF val = &T::f; // ok
43 }
44};