[all-commits] [llvm/llvm-project] f2639c: [randstruct] Move initializer check to be more eff...
Bill Wendling via All-commits
all-commits at lists.llvm.org
Tue May 3 11:23:44 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f2639cf3fe46c30ad450cc2533c81eacd4788c33
https://github.com/llvm/llvm-project/commit/f2639cf3fe46c30ad450cc2533c81eacd4788c33
Author: Bill Wendling <isanbard at gmail.com>
Date: 2022-05-03 (Tue, 03 May 2022)
Changed paths:
M clang/lib/Sema/SemaInit.cpp
M clang/test/Sema/init-randomized-struct.c
Log Message:
-----------
[randstruct] Move initializer check to be more effective
If a randomized structure has an initializer with a dedicated
initializer in it, the field initialzed by that dedicated initializer
may end up at the end of the RecordDecl. This however may skip the
random layout initization check.
struct t {
int a, b, c, d, e;
} x = { .a = 2, 4, 5, 6 };
Let's say that "a" is lands as the last field after randomization. The
call to CheckDesignatedInitializer sets the iterator to the end of the
initializer list. During the next iteration of the initializer list
check, it detects that and fails to issue the error about initializing
a randomized struct with non-designated initializer. Instead, it issues
an error about "excess elements in struct initializer", which is
confusing under these circumstances.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D124694
More information about the All-commits
mailing list