void added a comment. In D124694#3485585 <https://reviews.llvm.org/D124694#3485585>, @aaron.ballman wrote:
> struct t { > int a, b, c, d, e; > } x = { .a = 2, 4, 5, 6 }; > > This situation seems like it should be an error, shouldn't it? The user > specified one designated initializer (yay, that one is correct), but the rest > are positional initializers and so there's no telling what they actually > initialize due to field randomization. That is diagnosed as an error. The issue is that after randomization, the `a` field is placed at the end of the structure. The initializer checker then sees the `.a = 2` and says, "Ah! That's the one at the end of the structure. Any non-designated initializers afterwards will be excess ones," which is what happens. But that warning is completely mysterious to the end users who isn't told that they can't have a non-designated initializer on a randomized structure. Moving the diagnostic allows the correct warning to be emitted instead of the "excess elements" one. ================ Comment at: clang/test/Sema/init-randomized-struct.c:1 -// RUN: %clang_cc1 -triple=x86_64-unknown-linux -frandomize-layout-seed=1234567890abcdef \ +// RUN: %clang_cc1 -triple=x86_64-unknown-linux -frandomize-layout-seed=1234567890abcded \ // RUN: -verify -fsyntax-only -Werror %s ---------------- aaron.ballman wrote: > Why is this change needed? > > (Also, shouldn't there be other test coverage added to the file?) That seed is how to replicate this issue. The test exists and is triggered by this change. I can add a comment to that effect. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124694/new/ https://reviews.llvm.org/D124694 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits