diff options
Diffstat (limited to 'locale/weightwc.h')
-rw-r--r-- | locale/weightwc.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/locale/weightwc.h b/locale/weightwc.h index ab26482996..7ee335dc9a 100644 --- a/locale/weightwc.h +++ b/locale/weightwc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper, <drepper@cygnus.com>. @@ -19,6 +19,8 @@ #ifndef _WEIGHTWC_H_ #define _WEIGHTWC_H_ 1 +#include <libc-diag.h> + /* Find index of weight. */ static inline int32_t __attribute__ ((always_inline)) findidx (const int32_t *table, @@ -26,7 +28,15 @@ findidx (const int32_t *table, const wint_t *extra, const wint_t **cpp, size_t len) { + /* With GCC 7 when compiling with -Os the compiler warns that + seq1.back_us and seq2.back_us, which become *cpp, might be used + uninitialized. This is impossible as this function cannot be + called except in cases where those fields have been + initialized. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); wint_t ch = *(*cpp)++; + DIAG_POP_NEEDS_COMMENT; int32_t i = __collidx_table_lookup ((const char *) table, ch); if (i >= 0) @@ -59,9 +69,17 @@ findidx (const int32_t *table, already. */ size_t cnt; + /* With GCC 5.3 when compiling with -Os the compiler warns + that seq2.back_us, which becomes usrc, might be used + uninitialized. This can't be true because we pass a length + of -1 for len at the same time which means that this loop + never executes. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); for (cnt = 0; cnt < nhere && cnt < len; ++cnt) if (cp[cnt] != usrc[cnt]) break; + DIAG_POP_NEEDS_COMMENT; if (cnt == nhere) { @@ -80,23 +98,37 @@ findidx (const int32_t *table, size_t cnt; size_t offset; + /* With GCC 7 when compiling with -Os the compiler warns + that seq1.back_us and seq2.back_us, which become usrc, + might be used uninitialized. This is impossible for the + same reason as described above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); for (cnt = 0; cnt < nhere - 1 && cnt < len; ++cnt) if (cp[cnt] != usrc[cnt]) break; + DIAG_POP_NEEDS_COMMENT; - if (cnt < nhere - 1) + if (cnt < nhere - 1 || cnt == len) { cp += 2 * nhere; continue; } - if (cp[nhere - 1] > usrc[nhere -1]) + /* With GCC 7 when compiling with -Os the compiler warns + that seq1.back_us and seq2.back_us, which become usrc, + might be used uninitialized. This is impossible for the + same reason as described above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); + if (cp[nhere - 1] > usrc[nhere - 1]) { cp += 2 * nhere; continue; } + DIAG_POP_NEEDS_COMMENT; - if (cp[2 * nhere - 1] < usrc[nhere -1]) + if (cp[2 * nhere - 1] < usrc[nhere - 1]) { cp += 2 * nhere; continue; |