From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Subject: [patchset] rewrite of initializer handling
Date: Mon, 18 Jun 2007 11:19:29 +0100 [thread overview]
Message-ID: <20070618101929.GE21478@ftp.linux.org.uk> (raw)
Current tree handling of initializers is rather incomplete
and in many cases broken. Patchset rewrites that stuff pretty much
from scratch; AFAICS it works.
Fixed:
* proper walking into subobjects, with warnings about missing
braces. Current tree doesn't handle that and in the best case we
get a warning when initializer hits the wrong subobject and gets a type
mismatch; in the worst case we get nothing.
* excess of initializer list elements is reported
* unnamed bitfields are skipped as the should be; the current tree
doesn't do that
* fixed handling of string literals; current tree is inconsistent
in that area, especially when they come from inlined functions
(evaluate_expression() changes expr->type, so it's not recognized as string
literal the next time aroung).
* fixed handling of struct/union assignment-style initializers.
* fixed handling of gccisms (unnamed union as a member, empty struct
as a member) to match gcc behaviour; gcc extension allowing ("a") to be
treated as "a" is handled, with a warning conditional on -Wparen-string
(default is off). BTW, several places in the kernel have that sort of
idiocy.
Areas still missing:
* wide string literals. We don't support wide char anyway, so...
* expand doesn't care for order of initializers. For overlapping
ones that becomes a problem, especially when mixed with gcc range
designators (e.g. [20 ... 100] = {1, 2}, [0 ... 30].a = 15, [49] = {15, 20})
* expand still leaves EXPR_POS -> EXPR_POS -> EXPR_VALUE for
[0 ... 1][0] = 1, which makes compile-i386.c rather unhappy (segfaults).
While we are at it, compile-i386.c apparently is unaware of range designators
at all - it ignores the count. Probably best fixed in compile-i386.c...
* calculation of array size by initializer is still broken; at least
now we get warnings about missing braces in the cases that trigger that
crap; struct {int a, b;} a[] = {1,2,3,4,5}; should give a 3-element array,
not 5-element one. New code warns about missing braces and puts the values
in right places, but it still doesn't fix the array size calculation - it's
done too early. Since evaluate_initializer() can work with array of
unknown size, perhaps the best solution would be to call it from the
count_array_initializer() and look for maximal index in the results if
we have EXPR_INITIALIZER / look for string size otherwise (no other
variants are possible for arrays). Objections?
Have fun... The tree is in branch 'initializers' of
git://git.kernel.org//pub/scm/linux/kernel/git/viro/sparse/
Al Viro (4):
make copying of EXPR_INDEX non-lazy
tie the fields of struct in simple list
rewrite of initializer handling
fix handling of typeof on structs
evaluate.c | 569 ++++++++++++++++++++++++++++++++++++++++------------------
expression.h | 1 +
inline.c | 2 -
lib.c | 2 +
lib.h | 1 +
parse.c | 20 ++-
symbol.c | 7 +-
symbol.h | 6 +-
8 files changed, 428 insertions(+), 180 deletions(-)
next reply other threads:[~2007-06-18 10:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-18 10:19 Al Viro [this message]
2007-06-18 10:26 ` [patchset] rewrite of initializer handling Al Viro
2007-06-18 17:07 ` Linus Torvalds
2007-06-18 18:02 ` Josh Triplett
2007-06-18 19:30 ` Al Viro
2007-06-18 18:19 ` Josh Triplett
2007-06-18 19:16 ` Al Viro
2007-06-18 19:27 ` Linus Torvalds
2007-06-18 21:46 ` Michael Stefaniuc
2007-06-18 22:43 ` Al Viro
2007-06-19 9:47 ` Michael Stefaniuc
2007-06-19 20:15 ` Michael Stefaniuc
2007-06-19 22:41 ` Al Viro
2007-06-20 8:54 ` Michael Stefaniuc
2007-06-20 21:29 ` Michael Stefaniuc
-- strict thread matches above, loose matches on Subject: below --
2007-06-19 17:12 Alexey Dobriyan
2007-06-19 17:21 ` Al Viro
2007-06-19 22:33 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070618101929.GE21478@ftp.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-sparse@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.