This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Preprocessor: some dollars-in-identifiers mishap broke cris-axis-elf
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Jun 2003 21:16:59 +0100
- Subject: Re: Preprocessor: some dollars-in-identifiers mishap broke cris-axis-elf
- References: <Pine.BSF.4.44.0305220146170.85842-100000@dair.pair.com> <Pine.BSF.4.44.0306100817490.92384-100000@dair.pair.com>
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.