1 | // RUN: %check_clang_tidy %s cert-err33-c %t |
---|---|
2 | |
3 | typedef __SIZE_TYPE__ size_t; |
4 | void *aligned_alloc(size_t alignment, size_t size); |
5 | void test_aligned_alloc(void) { |
6 | aligned_alloc(alignment: 2, size: 10); |
7 | // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
8 | // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
9 | } |
10 | |
11 | long strtol(const char *restrict nptr, char **restrict endptr, int base); |
12 | void test_strtol(void) { |
13 | strtol("123", 0, 10); |
14 | // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
15 | // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
16 | } |
17 | |
18 | typedef char wchar_t; |
19 | int wscanf_s(const wchar_t *restrict format, ...); |
20 | void test_wscanf_s(void) { |
21 | int Val; |
22 | wscanf_s("%i", &Val); |
23 | // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
24 | // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
25 | } |
26 | |
27 | int remove(const char *path); |
28 | int removeNonStdLibFunc(const char *path); |
29 | void test_remove(void) { |
30 | remove(path: "123"); |
31 | // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors |
32 | // CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning |
33 | removeNonStdLibFunc(path: "123"); |
34 | } |
35 |