1 | // RUN: %check_clang_tidy %s misc-non-copyable-objects %t |
2 | |
3 | namespace std { |
4 | typedef struct FILE {} FILE; |
5 | } |
6 | using namespace std; |
7 | |
8 | // CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? [misc-non-copyable-objects] |
9 | void g(std::FILE f); |
10 | |
11 | struct S { |
12 | // CHECK-MESSAGES: :[[@LINE+1]]:10: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? |
13 | ::FILE f; |
14 | }; |
15 | |
16 | void func(FILE *f) { |
17 | // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: 'f1' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? |
18 | std::FILE f1; // match |
19 | // CHECK-MESSAGES: :[[@LINE+2]]:10: warning: 'f2' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? |
20 | // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced |
21 | ::FILE f2 = *f; // match, match |
22 | // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: 'f3' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? |
23 | struct FILE f3; // match |
24 | // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced |
25 | (void)sizeof(*f); // match |
26 | } |
27 | |