New attribute designated_init: mark a struct as requiring designated init
commitf09699fa80b3b15b94b3e1878ac6cdfdb48f43ac
authorJosh Triplett <josh@joshtriplett.org>
Sun, 11 Oct 2009 22:51:56 +0000 (11 22:51 +0000)
committerChristopher <sparse@chrisli.org>
Mon, 29 Mar 2010 00:51:36 +0000 (28 17:51 -0700)
treee29fe5fb76dbba97a7dad2eda54de4a694c53a51
parentc0d5c5dcb0c673afeeafadab6bf5fdef8f904ce3
New attribute designated_init: mark a struct as requiring designated init

Some structure types provide a set of fields of which most users will
only initialize the subset they care about.  Users of these types should
always use designated initializers, to avoid relying on the specific
structure layout.  Examples of this type of structure include the many
*_operations structures in Linux, which contain a set of function
pointers; these structures occasionally gain a new field, lose an
obsolete field, or change the function signature for a field.

Add a new attribute designated_init; when used on a struct, it tells
Sparse to warn on any positional initialization of a field in that
struct.

The new flag -Wdesignated-init controls these warnings.  Since these
warnings only fire for structures explicitly tagged with the attribute,
enable the warning by default.

Includes documentation and test case.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
cgcc
evaluate.c
lib.c
lib.h
parse.c
sparse.1
symbol.h
validation/designated-init.c [new file with mode: 0644]