]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't warn on dollars in builtin macro definitions,
authorHans-Peter Nilsson <hp@axis.com>
Thu, 12 Jun 2003 06:09:15 +0000 (06:09 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Thu, 12 Jun 2003 06:09:15 +0000 (06:09 +0000)
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

gcc/ChangeLog
gcc/c-opts.c
gcc/cpphash.h
gcc/cppinit.c
gcc/cpplex.c
gcc/cpplib.h

index f23fe499c931203589430b090c04a9f98d764521..1e9547180885ebf2d97c8a93cbebd0e6a4e33235 100644 (file)
@@ -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*,
index 43057ab551cafbcf6ef0ec6b36446d54521d2bd9..6f449a00bb347c9f7bff77ece3e1a52af59970d7 100644 (file)
@@ -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++)
        {
index aa5eec4e9d44018183acfe27d212d0873c9531d2..88addeac4d5c5172dd700167cb63ef56379d860a 100644 (file)
@@ -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;
 
index d6e7ae426d2ec190c45d32e1d7c01ad8709c366d..cace8b9f5db9f5d6081a5a369387b6435ac1cf83 100644 (file)
@@ -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);
 }
index a79bedd154db28029cf9b0df48b6f33960d0b19f..e072f01bdcf0ff60103c6c23ebb34986b356efe1 100644 (file)
@@ -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");
        }
 
index a47a7fbf077fd1e0982b220359e28feef3fe6177..45142527ea20034677ed4e782fc804cefaf3d398 100644 (file)
@@ -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;