diff options
author | Milek7 <Milek7@users.noreply.github.com> | 2021-04-28 23:06:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 22:06:47 +0100 |
commit | 8e9eca6dddf238c77f01d93afcefcca262447e98 (patch) | |
tree | 334d6cee0f31e52b9f3108a3d05aad16b272ae6e /src | |
parent | 267703c14be579b168125e2b3fbab2e407638ced (diff) | |
download | openttd-8e9eca6dddf238c77f01d93afcefcca262447e98.tar.xz |
Codechange: Use __attribute__ access none to silence GCC 11 -Wmaybe-uninitialized warnings (#9124)
Diffstat (limited to 'src')
-rw-r--r-- | src/stdafx.h | 6 | ||||
-rw-r--r-- | src/string_func.h | 16 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/stdafx.h b/src/stdafx.h index 6a3322345..19009f5ff 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -138,6 +138,12 @@ # endif #endif /* __GNUC__ || __clang__ */ +#if __GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1) +# define NOACCESS(args) __attribute__ ((access (none, args))) +#else +# define NOACCESS(args) +#endif + #if defined(__WATCOMC__) # define NORETURN # define CDECL diff --git a/src/string_func.h b/src/string_func.h index 6c894b3cb..4fe9d7b82 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -30,25 +30,25 @@ #include "core/bitmath_func.hpp" #include "string_type.h" -char *strecat(char *dst, const char *src, const char *last); -char *strecpy(char *dst, const char *src, const char *last); -char *stredup(const char *src, const char *last = nullptr); +char *strecat(char *dst, const char *src, const char *last) NOACCESS(3); +char *strecpy(char *dst, const char *src, const char *last) NOACCESS(3); +char *stredup(const char *src, const char *last = nullptr) NOACCESS(2); -int CDECL seprintf(char *str, const char *last, const char *format, ...) WARN_FORMAT(3, 4); -int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap) WARN_FORMAT(3, 0); +int CDECL seprintf(char *str, const char *last, const char *format, ...) WARN_FORMAT(3, 4) NOACCESS(2); +int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap) WARN_FORMAT(3, 0) NOACCESS(2); char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2); -void str_validate(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); +void str_validate(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK) NOACCESS(2); std::string str_validate(const std::string &str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); void ValidateString(const char *str); -void str_fix_scc_encoded(char *str, const char *last); +void str_fix_scc_encoded(char *str, const char *last) NOACCESS(2); void str_strip_colours(char *str); bool strtolower(char *str); bool strtolower(std::string &str, std::string::size_type offs = 0); -bool StrValid(const char *str, const char *last); +bool StrValid(const char *str, const char *last) NOACCESS(2); void StrTrimInPlace(char *str); /** |