[PATCH] comments handling fix in sparse
commit758eba2b81ccacce770a719792a93c12a7a9e45b
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Sun, 13 Jun 2004 15:13:32 +0000 (13 08:13 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 8 Apr 2005 04:02:06 +0000 (7 21:02 -0700)
treee70c295b2297a1864351d297b9902b8c2ff9a9bd
parentdbcef7760a47160bac2c9eba3f9ac68b46fde9cb
[PATCH] comments handling fix in sparse

If we get a newline in the middle of a comment, stream->pos.newline
is set and remains set.  In effect, newlines in the middle of multiline
comments drift to its end.  This is wrong - e.g.

#define A /* foo
*/ B

is 100% legitimate - since every comment is treated as if replaced with
single space, the above is equivalent to

#define A B

Current code treats it as

#define A
B

which is bogus.  Fix is trivial - we simply should restore ->newline we had
at the beginning of comment once we finish skipping it.

BTW, I'm starting to put new testcases into subdirectories - by translation
phase (multibyte character mapping == phase 1, line-splicing == phase 2,
tokenizer == phase 3, macro-expansion == phase 4, remapping from source
charset to execution charset == phase 5, merging adjacent string constants
== phase 6, conversion of tokens from preprocessor to compiler ones and
translation proper == phase 7, linking == phase 8).  We obviously don't
have many of those (no multibyte handling, source and execution charsets
are identical and having no backend we obviously do not link anything),
but it's easier to keep track of what's what in the tests that way.  We
already have way too many preprocessor<n>.c in there and going for saner
names will only create confusion between preprocessor and parser tests.

I'm not moving existing testcases - that's just for new ones...
tokenize.c
validation/phase3/comments [new file with mode: 0644]