diff --git a/cmd/wuffs-c/internal/cgen/cgen.go b/cmd/wuffs-c/internal/cgen/cgen.go index f8dd8c29..3e85152b 100644 --- a/cmd/wuffs-c/internal/cgen/cgen.go +++ b/cmd/wuffs-c/internal/cgen/cgen.go @@ -1006,9 +1006,18 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error { b.writes("}\n\n") b.writes("if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {\n") + b.writes(" // The whole point of this if-check is to detect an uninitialized *self.\n") + b.writes(" // We disable the warning on GCC. Clang-5.0 does not have this warning.\n") + b.writes(" #if !defined(__clang__) && defined(__GNUC__)\n") + b.writes(" #pragma GCC diagnostic push\n") + b.writes(" #pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n") + b.writes(" #endif\n") b.writes(" if (self->private_impl.magic != 0) {\n") b.writes(" return wuffs_base__error__initialize_falsely_claimed_already_zeroed;\n") b.writes(" }\n") + b.writes(" #if !defined(__clang__) && defined(__GNUC__)\n") + b.writes(" #pragma GCC diagnostic pop\n") + b.writes(" #endif\n") b.writes("} else {\n") b.writes(" void* p = &(self->private_impl);\n") b.writes(" size_t n = sizeof(self->private_impl);\n") diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 028dedca..95b0c264 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -4999,9 +4999,18 @@ wuffs_adler32__hasher__initialize(wuffs_adler32__hasher* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl); @@ -6010,9 +6019,18 @@ wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl); @@ -6300,9 +6318,18 @@ wuffs_deflate__decoder__initialize(wuffs_deflate__decoder* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl); @@ -8098,9 +8125,18 @@ wuffs_lzw__decoder__initialize(wuffs_lzw__decoder* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl); @@ -8684,9 +8720,18 @@ wuffs_gif__decoder__initialize(wuffs_gif__decoder* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl); @@ -10862,9 +10907,18 @@ wuffs_gzip__decoder__initialize(wuffs_gzip__decoder* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl); @@ -11348,9 +11402,18 @@ wuffs_zlib__decoder__initialize(wuffs_zlib__decoder* self, } if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) { +// The whole point of this if-check is to detect an uninitialized *self. +// We disable the warning on GCC. Clang-5.0 does not have this warning. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (self->private_impl.magic != 0) { return wuffs_base__error__initialize_falsely_claimed_already_zeroed; } +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { void* p = &(self->private_impl); size_t n = sizeof(self->private_impl);