1// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \
2// RUN: -- -std=c11 -I %S/Inputs/not-null-terminated-result
3
4#include "not-null-terminated-result-c.h"
5
6#define __STDC_LIB_EXT1__ 1
7#define __STDC_WANT_LIB_EXT1__ 1
8#undef __STDC_WANT_LIB_EXT1__
9
10void f(const char *src) {
11 char dest[13];
12 memcpy_s(dest, 13, src, strlen(src) - 1);
13 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'memcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
14 // CHECK-FIXES: char dest[14];
15 // CHECK-FIXES-NEXT: strncpy_s(dest, 14, src, strlen(src) - 1);
16}
17
18

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-undef-stdc-want-lib-ext1.c