[LinuxBIOS] romcc and preprocessor problems

Eric W. Biederman ebiederman at lnxi.com
Sat Dec 2 15:47:52 CET 2006


Ben Hewson <ben at hewson-venieri.com> writes:

> Hi Eric
>
> Please find attached some simple test cases.
> These were compiled using the following
>
>
>
> ./romcc -O  -fno-eliminate-inefectual-code
> -I../../../../../src/arch/i386/include/  -o testdef3.inc  testdef3.c
>
> if you look at testdef2.c, testdef2.inc you can see that a C++ comment
> has caused one line to be missed, no comment or a C comment are fine. I
> checked no comments, C comments and C++ comments on both the #if and
> #else lines. The one thing I did not check was a C++ comment on the
> #endif to see if the following line was missed.
>
> I may be missing needed options for romcc, but I have tried similar
> tests in a proper build, with the same results.

I took a quick look and it turns out the problem was the tokenizer was
treating the newline as part of the EOL comment.  This only showed
up in the preprocessor because that really the only place that cares
about seeing the EOL token separately from a space.

Please test the attached patch.  Thanks.

Eric
--- ../romcc-0.64/romcc.c	2006-12-02 07:39:11.000000000 -0700
+++ romcc.c	2006-12-02 07:41:23.000000000 -0700
@@ -4027,10 +4027,15 @@
 		tok = TOK_SPACE;
 		tokp = next_char(file, tokp, 1);
 		while((c = get_char(file, tokp)) != -1) {
-			tokp = next_char(file, tokp, 1);
+			/* Advance to the next character only after we verify
+			 * the current character is not a newline.  
+			 * EOL is special to the preprocessor so we don't
+			 * want to loose any.
+			 */
 			if (c == '\n') {
 				break;
 			}
+			tokp = next_char(file, tokp, 1);
 		}
 	}
 	/* Comments */




More information about the coreboot mailing list