[llvm] [clang] [clang-tools-extra] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 02:16:45 PST 2023
mikaelholmen wrote:
Hi @Fznamznon and others!
It looks like this patch not only avoids a false positive, but it also causes warnigns on stuff it didn't warn on before.
So if I add the following to clang/test/Sema/missing-field-initializers.c
```
struct S1 {
long int l;
struct { int a, b; } d1;
};
struct S1 s01 = { 1, {1} }; // expected-warning {{missing field 'b' initializer}}
struct S1 s02 = { .d1.a = 1 };
union U1 {
long int l;
struct { int a, b; } d1;
};
union U1 u01 = { 1 };
union U1 u02 = { .d1.a = 1 };
```
Without the patch it's silent, but with the patch I get
```
File /repo/uabelho/main-github/clang/test/Sema/missing-field-initializers.c Line 11: missing field 'b' initializer
File /repo/uabelho/main-github/clang/test/Sema/missing-field-initializers.c Line 19: missing field 'b' initializer
```
so it warns on
```
struct S1 s02 = { .d1.a = 1 };
```
and
```
union U1 u02 = { .d1.a = 1 };
```
I suppose this is not as expected?
We see thousands of warnings like this with our downstream compiler.
https://github.com/llvm/llvm-project/pull/70829
More information about the llvm-commits
mailing list