Preprocessor: some dollars-in-identifiers mishap broke cris-axis-elf
Neil Booth
neil@daikokuya.co.uk
Tue Jun 10 20:17:00 GMT 2003
Hans-Peter Nilsson wrote:-
> > Excess errors:
> > <built-in>:56:21: warning: '$' in identifier or number
> >
> > "everywhere" (1000:s of test-cases) for example
> > gcc.dg/20000111-1.c. Note #define REGISTER_PREFIX "$" but
> > that's all dollar-wise.
>
> As I guessed, it's exactly (in a callee of) the
> builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
> in c-cppbuiltin.c that the warning is emitted.
>
> I think GCC shouldn't warn on that macro definition in
> particular and perhaps not on builtin definitions in general.
>
> Neil, what's preferred and what's the best way to accomplish it?
The warning is controlled by a flag warn_dollars. How about refining
when this is set?
Currently cppinit.c has:
pfile->warn_dollars = CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile,
c99);
This is a cpp-internal flag in cpp_reader. I suggest we make it settable
by the client (i.e. cc1) by putting it in the cpp_options structure and
remove the above line, that cpplib as a library defaults to true in
cpp_create_reader, and that c_common_post_options does
cpp_opts->warn_dollars = (CPP_PEDANTIC (pfile)
&& !CPP_OPTION (pfile, c99)
&& DOLLARS_IN_IDENTIFIERS);
or something similar, so that dollar targets only warn if both not
c99 and pedantic. Note that cpplib must not have target dependencies,
of which DOLLARS_IN_IDENTIFIERS is one.
Since you have this issue, if you're happy with my suggestion, could
you create and test a patch along the above lines? Such a patch is
pre-approved.
Thanks,
Neil.
More information about the Gcc-bugs
mailing list