This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

cpp problem with asm


Hi guys,

First off, I know there have been points made here that cpp is not
supported with languages other than C/C++, and I've read the relevant bit
of cpp.texi. 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:

The issue is revealed in the following snippet. The "# foo" etc. would be
assembler comments.

#if 0           // must be false
        # foo
        # fee
        # fie
        # foe   only this one
        # fum   and this one are reported
        
#elif 0         // dont care
        # bundy
#endif

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

Curiously, as described, this only matters when a #elif is present and the
#if is false. The only tokens reported are the latter two.

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.

So can anyone wiser about cpp have a look or give me more pointers? Thanks.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Un cheval, pas du glue. Pas du cheval, beaucoup du glue. || Opinions==mine

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]