[PATCH] D157879: [clang] Report missing designated initializers in C++

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 21 10:43:53 PDT 2023


aaron.ballman added a comment.

In D157879#4604233 <https://reviews.llvm.org/D157879#4604233>, @aeubanks wrote:

> ah I thought this was in `-Wall` but it's not
>
> the struct is
>
>   struct Foo {
>     const void* buffer;
>     uint32_t capacity;
>     uint32_t reserved;
>   };
>
> where `reserved` isn't explicitly initialized. that seems like reasonable code, but I suppose we can just explicitly initialize `reserved` here

Thank you for sharing the use case, that's actually a rather interesting one! Leaving the identifier `reserved` off the field would trigger a `-Wmissing-declarations` diagnostic (which is on by default). You can leave the field named and use an in-class initializer for it and that should silence the diagnostic. But I kind of wonder if we want to special case fields named `reserved` or similar (`wReserved`, `reserved2`, etc)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157879/new/

https://reviews.llvm.org/D157879



More information about the cfe-commits mailing list