xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/cert/err33-c.c (revision 543f9e781032f086afa7438065b9ce7a9c07ca2b)
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);
test_aligned_alloc(void)5 void test_aligned_alloc(void) {
6   aligned_alloc(2, 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);
test_strtol(void)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, ...);
test_wscanf_s(void)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