1 | // RUN: %check_clang_tidy %s bugprone-multi-level-implicit-pointer-conversion %t |
2 | |
3 | using OneStar = void*; |
4 | using OneStarFancy = OneStar; |
5 | |
6 | void takeFirstLevelVoidPtr(OneStar message); |
7 | void takeFirstLevelConstVoidPtr(const OneStarFancy message); |
8 | void takeFirstLevelConstVoidPtrConst(const void* const message); |
9 | void takeSecondLevelVoidPtr(void** message); |
10 | |
11 | void** getSecondLevelVoidPtr(); |
12 | void* getFirstLevelVoidPtr(); |
13 | int** getSecondLevelIntPtr(); |
14 | int* getFirstLevelIntPtr(); |
15 | |
16 | int table[5]; |
17 | |
18 | void test() |
19 | { |
20 | void** secondLevelVoidPtr; |
21 | int* firstLevelIntPtr; |
22 | |
23 | // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
24 | void* a = getSecondLevelVoidPtr(); |
25 | |
26 | void** b = getSecondLevelVoidPtr(); |
27 | void* c = getFirstLevelVoidPtr(); |
28 | |
29 | // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: multilevel pointer conversion from 'int **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
30 | void* d = getSecondLevelIntPtr(); |
31 | |
32 | takeFirstLevelVoidPtr(message: &table); |
33 | |
34 | takeFirstLevelVoidPtr(message: firstLevelIntPtr); |
35 | |
36 | takeFirstLevelVoidPtr(message: getFirstLevelIntPtr()); |
37 | |
38 | // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
39 | takeFirstLevelVoidPtr(message: secondLevelVoidPtr); |
40 | |
41 | // CHECK-MESSAGES: :[[@LINE+1]]:30: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
42 | takeFirstLevelConstVoidPtr(message: secondLevelVoidPtr); |
43 | |
44 | // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: multilevel pointer conversion from 'void **' to 'const void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
45 | takeFirstLevelConstVoidPtrConst(message: secondLevelVoidPtr); |
46 | |
47 | // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: multilevel pointer conversion from 'void ***' to 'const void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
48 | takeFirstLevelConstVoidPtrConst(message: &secondLevelVoidPtr); |
49 | |
50 | takeSecondLevelVoidPtr(message: secondLevelVoidPtr); |
51 | |
52 | // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
53 | takeFirstLevelVoidPtr(message: getSecondLevelVoidPtr()); |
54 | |
55 | // CHECK-MESSAGES: :[[@LINE+1]]:30: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
56 | takeFirstLevelConstVoidPtr(message: getSecondLevelVoidPtr()); |
57 | |
58 | // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: multilevel pointer conversion from 'void **' to 'const void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
59 | takeFirstLevelConstVoidPtrConst(message: getSecondLevelVoidPtr()); |
60 | |
61 | // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: multilevel pointer conversion from 'int **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] |
62 | takeFirstLevelVoidPtr(message: getSecondLevelIntPtr()); |
63 | |
64 | takeSecondLevelVoidPtr(message: getSecondLevelVoidPtr()); |
65 | } |
66 | |