[PATCH] D98548: [clang][Sema] Don't try to initialize implicit variable of invalid anonymous union/struct

Ta-Wei Tu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 22 00:47:26 PDT 2021


TaWeiTu added a comment.

In D98548#2625593 <https://reviews.llvm.org/D98548#2625593>, @tmatheson wrote:

> This seems quite an early point to bail out, so it will prevent some errors/warnings associated with initialization from being emitted. For example, this warning is currently emitted but would be suppressed by this patch:
>
>   union {
>     virtual int a();
>     int b = 'c'; // expected-warning {{in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]}}
>   }
>
> I don't know how much that matters seeing as the union is invalid by this point.

Hi,

Thanks for the comment!
I understand the problem, but the warning you mentioned is not suppressed in this patch from what I've seen.
After poking around, I saw that diagnostics related to anonymous unions are all emitted in another call to `ActOnUninitializedDecl` in the parser, which takes place before this check.
If I completely remove this call to `ActOnUninitializedDecl` (on line 5215 to be specific), all the failed testcases seem to be related to CodeGen, so I suspect that removing this call for invalid unions will not suppress further warnings/errors.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98548



More information about the cfe-commits mailing list