cpp problem with asm
Neil Booth
neil@daikokuya.demon.co.uk
Tue Jan 16 14:31:00 GMT 2001
Jonathan Larmour wrote:-
> Hi guys,
Hi Jonathan!
> [...]. Still, it is useful for preprocessing assembler, and even
> the driver recognises that by accepting .S files and passing
> -lang-asm to cpp0, which then knows to not complain about unknown
> directives (in cpplib.c:354). However there is still a problem:
Yup, you should be able to preprocess most assembler.
> The issue is revealed in the following snippet
> [...]
> If this is saved as foo.S, and compiled with (e.g.) "sh-elf-gcc -Wundef -E
> foo.S" with current gcc, we get:
>
> foo.S:6:11: warning: "fum" is not defined
> foo.S:5:11: warning: "foe" is not defined
> foo.S:5:11: missing binary operator
Hmmm...
How does this look?
bash-2.04$ cat /tmp/test.c
#if 0 // must be false
# foo
# fee
# fie
# foe
# fum
#elif 0 // dont care
# bundy
#endif
bash-2.04$ ./cpp0 -Wundef /tmp/test.c
bash-2.04$
:-)
> Curiously, as described, this only matters when a #elif is present
> and the #if is false. The only tokens reported are the latter two.
False conditional skipping bug, maybe?
> I think the code at cpplib.c:354 isn't correct. It does not result in the #
> and token just being output verbatim - instead it is put in the lookahead
> list for possible processing in subsequent directives. I think.
Close, but no cigar. You'd be a bit pissed if your "# fum" or
whatever disappeared from output wouldn't you? (Assuming we're not in
a false conditional, of course).
In fact, it's just a typo. Ages ago I updated this code to replace
pfile->skipping with buffer->was_skipping (because we now set
pfile->skipping to 0 in directives - skipping the directive name
wouldn't do, would it?), but missed 2 places. This is the second one
(unbelievable, yes, I know)!
IMHO this patch isn't obvious, though I think it's OK. I'll commit it
after I bootstrap and make check, so that means tomorrow morning UK
time.
Neil.
* cpplib.c (_cpp_handle_directive): Check buffer->was_skipping
not pfile->skipping (== 0).
Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.236
diff -u -p -r1.236 cpplib.c
--- cpplib.c 2001/01/13 18:39:26 1.236
+++ cpplib.c 2001/01/16 22:29:23
@@ -349,7 +349,7 @@ _cpp_handle_directive (pfile, indented)
}
}
}
- else if (dname.type != CPP_EOF && ! pfile->skipping)
+ else if (dname.type != CPP_EOF && ! buffer->was_skipping)
{
/* An unknown directive. Don't complain about it in assembly
source: we don't know where the comments are, and # may
More information about the Gcc-patches
mailing list