Commit 78b8811a by Hans-Peter Nilsson Committed by Hans-Peter Nilsson

Don't warn on dollars in builtin macro definitions,

	e.g. __REGISTER_PREFIX__.
	* cpphash.h (struct cpp_reader): Move member warn_dollars...
	* cpplib.h (struct cpp_options): ...to here.  Change type to
	unsigned char.
	* cppinit.c (cpp_create_reader): Set it to 1 here.
	(post_options): Don't set it here.
	* c-opts.c (c_common_init_options): Reset it to 0 here.
	(finish_options): Set it here.
	* cpplex.c (forms_identifier_p): Tweak for new location of
	warn_dollars.

From-SVN: r67824
parent ed446835
2003-06-12 Hans-Peter Nilsson <hp@axis.com>
Don't warn on dollars in builtin macro definitions,
e.g. __REGISTER_PREFIX__.
* cpphash.h (struct cpp_reader): Move member warn_dollars...
* cpplib.h (struct cpp_options): ...to here. Change type to
unsigned char.
* cppinit.c (cpp_create_reader): Set it to 1 here.
(post_options): Don't set it here.
* c-opts.c (c_common_init_options): Reset it to 0 here.
(finish_options): Set it here.
* cpplex.c (forms_identifier_p): Tweak for new location of
warn_dollars.
2003-06-11 Uwe Stieber <uwe@kaos-group.de> 2003-06-11 Uwe Stieber <uwe@kaos-group.de>
* config.gcc (arm*-*-kaos*, i[34567]86-*-kaos*, powerpc-*-kaos*, * config.gcc (arm*-*-kaos*, i[34567]86-*-kaos*, powerpc-*-kaos*,
......
...@@ -225,6 +225,11 @@ c_common_init_options (lang) ...@@ -225,6 +225,11 @@ c_common_init_options (lang)
ident_hash); ident_hash);
cpp_opts = cpp_get_options (parse_in); cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
/* Reset to avoid warnings on internal definitions. We set it just
before passing on command-line options to cpplib. */
cpp_opts->warn_dollars = 0;
if (flag_objc) if (flag_objc)
cpp_opts->objc = 1; cpp_opts->objc = 1;
...@@ -1356,6 +1361,18 @@ finish_options () ...@@ -1356,6 +1361,18 @@ finish_options ()
cpp_change_file (parse_in, LC_RENAME, _("<built-in>")); cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
cpp_init_builtins (parse_in, flag_hosted); cpp_init_builtins (parse_in, flag_hosted);
c_cpp_builtins (parse_in); c_cpp_builtins (parse_in);
/* We're about to send user input to cpplib, so make it warn for
things that we previously (when we sent it internal definitions)
told it to not warn.
C99 permits implementation-defined characters in identifiers.
The documented meaning of -std= is to turn off extensions that
conflict with the specified standard, and since a strictly
conforming program cannot contain a '$', we do not condition
their acceptance on the -std= setting. */
cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99);
cpp_change_file (parse_in, LC_RENAME, _("<command line>")); cpp_change_file (parse_in, LC_RENAME, _("<command line>"));
for (i = 0; i < deferred_count; i++) for (i = 0; i < deferred_count; i++)
{ {
......
...@@ -378,10 +378,6 @@ struct cpp_reader ...@@ -378,10 +378,6 @@ struct cpp_reader
cpp_token avoid_paste; cpp_token avoid_paste;
cpp_token eof; cpp_token eof;
/* True if we should warn about dollars in identifiers or numbers
for this translation unit. */
bool warn_dollars;
/* Opaque handle to the dependencies of mkdeps.c. */ /* Opaque handle to the dependencies of mkdeps.c. */
struct deps *deps; struct deps *deps;
......
...@@ -151,6 +151,7 @@ cpp_create_reader (lang, table) ...@@ -151,6 +151,7 @@ cpp_create_reader (lang, table)
CPP_OPTION (pfile, warn_deprecated) = 1; CPP_OPTION (pfile, warn_deprecated) = 1;
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99); CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, warn_dollars) = 1;
/* Default CPP arithmetic to something sensible for the host for the /* Default CPP arithmetic to something sensible for the host for the
benefit of dumb users like fix-header. */ benefit of dumb users like fix-header. */
...@@ -570,11 +571,4 @@ post_options (pfile) ...@@ -570,11 +571,4 @@ post_options (pfile)
CPP_OPTION (pfile, trigraphs) = 0; CPP_OPTION (pfile, trigraphs) = 0;
CPP_OPTION (pfile, warn_trigraphs) = 0; CPP_OPTION (pfile, warn_trigraphs) = 0;
} }
/* C99 permits implementation-defined characters in identifiers.
The documented meaning of -std= is to turn off extensions that
conflict with the specified standard, and since a strictly
conforming program cannot contain a '$', we do not condition
their acceptance on the -std= setting. */
pfile->warn_dollars = CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99);
} }
/* CPP Library - lexical analysis. /* CPP Library - lexical analysis.
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95. Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -402,9 +402,9 @@ forms_identifier_p (pfile, first) ...@@ -402,9 +402,9 @@ forms_identifier_p (pfile, first)
return false; return false;
buffer->cur++; buffer->cur++;
if (pfile->warn_dollars && !pfile->state.skipping) if (CPP_OPTION (pfile, warn_dollars) && !pfile->state.skipping)
{ {
pfile->warn_dollars = false; CPP_OPTION (pfile, warn_dollars) = 0;
cpp_error (pfile, DL_PEDWARN, "'$' in identifier or number"); cpp_error (pfile, DL_PEDWARN, "'$' in identifier or number");
} }
......
...@@ -300,6 +300,10 @@ struct cpp_options ...@@ -300,6 +300,10 @@ struct cpp_options
/* Zero means dollar signs are punctuation. */ /* Zero means dollar signs are punctuation. */
unsigned char dollars_in_ident; unsigned char dollars_in_ident;
/* True if we should warn about dollars in identifiers or numbers
for this translation unit. */
unsigned char warn_dollars;
/* Nonzero means warn if undefined identifiers are evaluated in an #if. */ /* Nonzero means warn if undefined identifiers are evaluated in an #if. */
unsigned char warn_undef; unsigned char warn_undef;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment