Preprocessor: some dollars-in-identifiers mishap broke cris-axis-elf
Hans-Peter Nilsson
hp@bitrange.com
Tue Jun 10 23:35:00 GMT 2003
On Tue, 10 Jun 2003, Neil Booth wrote:
> 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.
Yes I noticed that much when I pinpointed the message in GDB.
> How about refining
> when this is set?
The only refinement useful here is "never". Again, this was an
*internal definition* caused by a target macro unrelated to the
C language and actually unrelated to DOLLARS_IN_IDENTIFIERS.
Seriously; no, it's not a matter of refining a static setting;
any warning settings must instead be unset or ignored for
internal macro definitions that may be affected. Perhaps just
__REGISTER_PREFIX__ is affected.
> 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,
Nope, I'll come up with something different, perhaps for
__REGISTER_PREFIX__ only.
For the record (I checked the code), preprocessing asm (which
this *isn't really* about) will not get a dollar-warning, since
->dollars_in_ident is then 0.
brgds, H-P
More information about the Gcc-bugs
mailing list