diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f23fe499c931203589430b090c04a9f98d764521..1e9547180885ebf2d97c8a93cbebd0e6a4e33235 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +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> * config.gcc (arm*-*-kaos*, i[34567]86-*-kaos*, powerpc-*-kaos*, diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 43057ab551cafbcf6ef0ec6b36446d54521d2bd9..6f449a00bb347c9f7bff77ece3e1a52af59970d7 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -225,6 +225,11 @@ c_common_init_options (lang) ident_hash); cpp_opts = cpp_get_options (parse_in); 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) cpp_opts->objc = 1; @@ -1356,6 +1361,18 @@ finish_options () cpp_change_file (parse_in, LC_RENAME, _("<built-in>")); cpp_init_builtins (parse_in, flag_hosted); 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>")); for (i = 0; i < deferred_count; i++) { diff --git a/gcc/cpphash.h b/gcc/cpphash.h index aa5eec4e9d44018183acfe27d212d0873c9531d2..88addeac4d5c5172dd700167cb63ef56379d860a 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -378,10 +378,6 @@ struct cpp_reader cpp_token avoid_paste; 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. */ struct deps *deps; diff --git a/gcc/cppinit.c b/gcc/cppinit.c index d6e7ae426d2ec190c45d32e1d7c01ad8709c366d..cace8b9f5db9f5d6081a5a369387b6435ac1cf83 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -151,6 +151,7 @@ cpp_create_reader (lang, table) CPP_OPTION (pfile, warn_deprecated) = 1; CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99); CPP_OPTION (pfile, dollars_in_ident) = 1; + CPP_OPTION (pfile, warn_dollars) = 1; /* Default CPP arithmetic to something sensible for the host for the benefit of dumb users like fix-header. */ @@ -570,11 +571,4 @@ post_options (pfile) CPP_OPTION (pfile, 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); } diff --git a/gcc/cpplex.c b/gcc/cpplex.c index a79bedd154db28029cf9b0df48b6f33960d0b19f..e072f01bdcf0ff60103c6c23ebb34986b356efe1 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1,5 +1,5 @@ /* 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. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -402,9 +402,9 @@ forms_identifier_p (pfile, first) return false; 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"); } diff --git a/gcc/cpplib.h b/gcc/cpplib.h index a47a7fbf077fd1e0982b220359e28feef3fe6177..45142527ea20034677ed4e782fc804cefaf3d398 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -300,6 +300,10 @@ struct cpp_options /* Zero means dollar signs are punctuation. */ 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. */ unsigned char warn_undef;