From 75b95fa25df74fcd0498bf59e3524f20f594755d Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 22 Sep 2023 18:27:54 +0200 Subject: Add more __diagnose_as_builtin annotations --- include/wchar.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include/wchar.h') diff --git a/include/wchar.h b/include/wchar.h index dc73fab..e696ddf 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -56,6 +56,9 @@ extern "C" { #undef wmemmove #undef wmemset +#if __has_builtin(__builtin_fgetws) +__diagnose_as_builtin(__builtin_fgetws, 1, 2, 3) +#endif _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, int __n, FILE *__f) { @@ -69,6 +72,9 @@ _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #undef mbsnrtowcs +#if __has_builtin(__builtin_mbsnrtowcs) +__diagnose_as_builtin(__builtin_mbsnrtowcs, 1, 2, 3, 4, 5) +#endif _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, const char **__s, size_t __n, size_t __wn, mbstate_t *__st) @@ -90,6 +96,9 @@ _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, } #endif +#if __has_builtin(__builtin_mbsrtowcs) +__diagnose_as_builtin(__builtin_mbsrtowcs, 1, 2, 3, 4) +#endif _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, const char **__s, size_t __wn, mbstate_t *__st) @@ -104,6 +113,9 @@ _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, return __r; } +#if __has_builtin(__builtin_mbstowcs) +__diagnose_as_builtin(__builtin_mbstowcs, 1, 2, 3) +#endif _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, const char *__s, size_t __wn) { @@ -116,6 +128,9 @@ _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, /* FIXME clang */ #ifndef __clang__ +#if __has_builtin(__builtin_wcrtomb) +__diagnose_as_builtin(__builtin_wcrtomb, 1, 2, 3) +#endif _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) { if (__s && MB_LEN_MAX > __bos(__s, 2)) { @@ -134,6 +149,9 @@ _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) } #endif +#if __has_builtin(__builtin_wcscat) +__diagnose_as_builtin(__builtin_wcscat, 1, 2) +#endif _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, const wchar_t *__s) { @@ -144,6 +162,9 @@ _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, return __orig_wcscat(__d, __s); } +#if __has_builtin(__builtin_wcscpy) +__diagnose_as_builtin(__builtin_wcscpy, 1, 2) +#endif _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, const wchar_t *__s) { @@ -154,6 +175,9 @@ _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, return __orig_wcscpy(__d, __s); } +#if __has_builtin(__builtin_wcsncat) +__diagnose_as_builtin(__builtin_wcsncat, 1, 2, 3) +#endif _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, const wchar_t *__s, size_t __n) { @@ -171,6 +195,9 @@ _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, return __orig_wcsncat(__d, __s, __n); } +#if __has_builtin(__builtin_wcsncpy) +__diagnose_as_builtin(__builtin_wcsncpy, 1, 2, 3) +#endif _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, const wchar_t *__s, size_t __n) { @@ -184,6 +211,9 @@ _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #undef wcsnrtombs +#if __has_builtin(__builtin_wcsnrtombs) +__diagnose_as_builtin(__builtin_wcsnrtombs, 1, 2, 3, 4, 5) +#endif _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, const wchar_t **__s, size_t __wn, size_t __n, mbstate_t *__st) @@ -205,6 +235,9 @@ _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, } #endif +#if __has_builtin(__builtin_wcsrtombs) +__diagnose_as_builtin(__builtin_wcsrtombs, 1, 2, 3, 4) +#endif _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, const wchar_t **__s, size_t __n, mbstate_t *__st) @@ -219,6 +252,9 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, } __access(write_only, 1, 3) +#if __has_builtin(__builtin_wcstombs) +__diagnose_as_builtin(__builtin_wcstombs, 1, 2, 3) +#endif _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, const wchar_t *__ws, size_t __n) { @@ -229,6 +265,9 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, return __orig_wcstombs(__s, __ws, __n); } +#if __has_builtin(__builtin_wctomb) +__diagnose_as_builtin(__builtin_wctomb, 1, 2) +#endif _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) { size_t __b = __bos(__s, 0); @@ -238,6 +277,9 @@ _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) return __orig_wctomb(__s, __w); } +#if __has_builtin(__builtin_wmemcpy) +__diagnose_as_builtin(__builtin_wmemcpy, 1, 2, 3) +#endif _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, const wchar_t *__s, size_t __n) { @@ -248,6 +290,9 @@ _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, return __orig_wmemcpy(__d, __s, __n); } +#if __has_builtin(__builtin_wmemmove) +__diagnose_as_builtin(__builtin_wmemmove, 1, 2, 3) +#endif _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, const wchar_t *__s, size_t __n) { @@ -258,6 +303,9 @@ _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, return __orig_wmemmove(__d, __s, __n); } +#if __has_builtin(__builtin_wmemset) +__diagnose_as_builtin(__builtin_wmemset, 1, 2, 3) +#endif _FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s, wchar_t __c, size_t __n) { -- cgit v1.3