validation/sizeof-bool: fix broken test case

Since commit 2667c2d (sparse: Allow override of sizeof(bool) warning,
2014-02-26) the default has been not to warn on sizeof(bool).  This
means that the sizeof-bool test case now needs an explicit command in
order to trigger the warning it is testing.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
evaluate: split out implementation of compatible_assignment_types

This will allow us to reuse the logic when processing a transparent
union by checking each member in turn without printing a warning unless
none of the members match.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Support GCC's transparent unions

This stops warnings in code using socket operations with a modern glibc,
which otherwise result in warnings of the form:

	warning: incorrect type in argument 2 (invalid types)
	   expected union __CONST_SOCKADDR_ARG [usertype] __addr
	   got struct sockaddr *<noident>

Since transparent unions are only applicable to function arguments, we
create a new function to check that the types are compatible
specifically in this context.

Also change the wording of the existing warning slightly since sparse
does now support them.  The warning is left in case people want to avoid
using transparent unions.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Add warning about duplicate initializers

Noticed this while looking at an independent bug reported by Hans
Verkuil.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Use any previous initializer to size a symbol

When we size a symbol, we only have one initializer per symbol, but we
may have multiple symbol declarations for the same symbol.  So make sure
to walk the "same_symbol" chain to find the initializer, rather than
assuming it is attached to the current declaration.

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Add test case for extern array

Has report this bug which fix by Linus in the previous commit.
Sparse will report "cannot size expression" on the array size.
It is cause by the second extern declare with imcompleted size.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Add test case for anonymous union initializer

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Add test case for the ioc type check

Running sparse over this gives:

error: bad integer constant expression

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Fix error at anoymous unions

Ok, this fixes the warning, but we seem to still mess up the actual
initializer. It looks like some later phase gets the offset wrong, so
when we lay things out in memory, we'll put things at offset zero
(which is right for your test-case, but not if there was something
before that anonymous union).

Regardless, that only matters for real code generation, not for using
sparse as a semantic checker, so this patch is correct and is an
improvement.

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>