cppinit.c (COMMAND_LINE_OPTIONS): Give all relevant -W options their own entries.
authorZack Weinberg <zack@codesourcery.com>
Fri, 7 Jun 2002 22:24:30 +0000 (22:24 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Fri, 7 Jun 2002 22:24:30 +0000 (22:24 +0000)
* cppinit.c (COMMAND_LINE_OPTIONS): Give all relevant -W
options their own entries.
(parse_option): Clarify comment.
(cpp_handle_option): Remove 'ignore' parameter and OPT_W
special case.  Replace if/strcmp chain for -W options with
use of new OPT_* entries for them.
(cpp_handle_options): Update to match.
* cpplib.h: Remove last parameter to cpp_handle_option from prototype.
* c-decl.c, cp/decl2.c: Update call to cpp_handle_option.

From-SVN: r54352

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cppinit.c
gcc/cpplib.h

index 7c9251c41d26ebb935d9b6d477688dfde9ef16c4..7c56a1a6e6e4bf2a97e32be968421186d48dd36c 100644 (file)
@@ -1,3 +1,15 @@
+2002-06-07  Zack Weinberg  <zack@codesourcery.com>
+
+       * cppinit.c (COMMAND_LINE_OPTIONS): Give all relevant -W
+       options their own entries.
+       (parse_option): Clarify comment.
+       (cpp_handle_option): Remove 'ignore' parameter and OPT_W
+       special case.  Replace if/strcmp chain for -W options with
+       use of new OPT_* entries for them.
+       (cpp_handle_options): Update to match.
+       * cpplib.h: Remove last parameter to cpp_handle_option from prototype.
+       * c-decl.c: Update call to cpp_handle_option.
+
 2002-06-07  Akim Demaille  <akim@epita.fr>
 
        * gengtype-yacc.y (optionseqopt): Add the ending `;' to the action.
index 6c16801e4e24126666b1ad958f3e3896196cab1e..819e26e95961e39bee160c21d56357daee6c9e94 100644 (file)
@@ -502,7 +502,7 @@ c_decode_option (argc, argv)
     { "write-strings", &flag_const_strings }
   };
 
-  strings_processed = cpp_handle_option (parse_in, argc, argv, 0);
+  strings_processed = cpp_handle_option (parse_in, argc, argv);
 
   if (!strcmp (p, "-fhosted") || !strcmp (p, "-fno-freestanding"))
     {
index 74f93ee78be440fae7c63efd783d88c94e7d80bc..fd4cd32306e983bdd807035adc860f5f0be8d840 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-07  Zack Weinberg  <zack@codesourcery.com>
+
+       * decl2.c: Update call to cpp_handle_option.
+
 2002-06-07  H.J. Lu  (hjl@gnu.org)
 
        * decl2.c (flag_use_cxa_atexit): Set to DEFAULT_USE_CXA_ATEXIT.
index 75fd0326d1685520ce535f3814248c4353281c82..661ae3a9a9ef0dce3af7156efca15ea897bef695 100644 (file)
@@ -479,7 +479,7 @@ cxx_decode_option (argc, argv)
   int strings_processed;
   const char *p = argv[0];
 
-  strings_processed = cpp_handle_option (parse_in, argc, argv, 0);
+  strings_processed = cpp_handle_option (parse_in, argc, argv);
 
   if (p[0] == '-' && p[1] == 'f')
     {
index 9d6a105852a7f4c6e3bbb76767f91b589409b25b..1bb323f99883b9987baa3e2fb2ba8482770ffbf0 100644 (file)
@@ -1152,7 +1152,25 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("MT",                       no_tgt, OPT_MT)                         \
   DEF_OPT("P",                        0,      OPT_P)                          \
   DEF_OPT("U",                        no_mac, OPT_U)                          \
-  DEF_OPT("W",                        no_arg, OPT_W)  /* arg optional */      \
+  DEF_OPT("Wall",                     0,      OPT_Wall)                       \
+  DEF_OPT("Wcomment",                 0,      OPT_Wcomment)                   \
+  DEF_OPT("Wcomments",                0,      OPT_Wcomments)                  \
+  DEF_OPT("Wendif-labels",            0,      OPT_Wendif_labels)              \
+  DEF_OPT("Werror",                   0,      OPT_Werror)                     \
+  DEF_OPT("Wimport",                  0,      OPT_Wimport)                    \
+  DEF_OPT("Wno-comment",              0,      OPT_Wno_comment)                \
+  DEF_OPT("Wno-comments",             0,      OPT_Wno_comments)               \
+  DEF_OPT("Wno-endif-labels",         0,      OPT_Wno_endif_labels)           \
+  DEF_OPT("Wno-error",                0,      OPT_Wno_error)                  \
+  DEF_OPT("Wno-import",               0,      OPT_Wno_import)                 \
+  DEF_OPT("Wno-system-headers",       0,      OPT_Wno_system_headers)         \
+  DEF_OPT("Wno-traditional",          0,      OPT_Wno_traditional)            \
+  DEF_OPT("Wno-trigraphs",            0,      OPT_Wno_trigraphs)              \
+  DEF_OPT("Wno-undef",                0,      OPT_Wno_undef)                  \
+  DEF_OPT("Wsystem-headers",          0,      OPT_Wsystem_headers)            \
+  DEF_OPT("Wtraditional",             0,      OPT_Wtraditional)               \
+  DEF_OPT("Wtrigraphs",               0,      OPT_Wtrigraphs)                 \
+  DEF_OPT("Wundef",                   0,      OPT_Wundef)                     \
   DEF_OPT("d",                        no_arg, OPT_d)                          \
   DEF_OPT("fno-operator-names",       0,      OPT_fno_operator_names)         \
   DEF_OPT("fno-preprocessed",         0,      OPT_fno_preprocessed)           \
@@ -1228,10 +1246,7 @@ static const struct cl_option cl_options[] =
    command-line matches.  Returns its index in the option array,
    negative on failure.  Complications arise since some options can be
    suffixed with an argument, and multiple complete matches can occur,
-   e.g. -iwithprefix and -iwithprefixbefore.  Moreover, we need to
-   accept options beginning with -W that we do not recognise, but not
-   to swallow any subsequent command line argument; this is handled as
-   special cases in cpp_handle_option.  */
+   e.g. -pedantic and -pedantic-errors.  */
 static int
 parse_option (input)
      const char *input;
@@ -1290,14 +1305,12 @@ parse_option (input)
 
 /* Handle one command-line option in (argc, argv).
    Can be called multiple times, to handle multiple sets of options.
-   If ignore is non-zero, this will ignore unrecognized -W* options.
    Returns number of strings consumed.  */
 int
-cpp_handle_option (pfile, argc, argv, ignore)
+cpp_handle_option (pfile, argc, argv)
      cpp_reader *pfile;
      int argc;
      char **argv;
-     int ignore;
 {
   int i = 0;
   struct cpp_pending *pend = CPP_OPTION (pfile, pending);
@@ -1329,11 +1342,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
       if (cl_options[opt_index].msg)
        {
          arg = &argv[i][cl_options[opt_index].opt_len + 1];
-
-         /* Yuk. Special case for -W as it must not swallow
-            up any following argument.  If this becomes common, add
-            another field to the cl_options table.  */
-         if (arg[0] == '\0' && opt_code != OPT_W)
+         if (arg[0] == '\0')
            {
              arg = argv[++i];
              if (!arg)
@@ -1665,51 +1674,68 @@ cpp_handle_option (pfile, argc, argv, ignore)
          /* Add directory to end of path for includes.  */
          append_include_chain (pfile, xstrdup (arg), AFTER, 0);
          break;
-       case OPT_W:
-         /* Silently ignore unrecognised options.  */
-         if (!strcmp (argv[i], "-Wall"))
-           {
-             CPP_OPTION (pfile, warn_trigraphs) = 1;
-             CPP_OPTION (pfile, warn_comments) = 1;
-           }
-         else if (!strcmp (argv[i], "-Wtraditional"))
-           CPP_OPTION (pfile, warn_traditional) = 1;
-         else if (!strcmp (argv[i], "-Wtrigraphs"))
-           CPP_OPTION (pfile, warn_trigraphs) = 1;
-         else if (!strcmp (argv[i], "-Wcomment"))
-           CPP_OPTION (pfile, warn_comments) = 1;
-         else if (!strcmp (argv[i], "-Wcomments"))
-           CPP_OPTION (pfile, warn_comments) = 1;
-         else if (!strcmp (argv[i], "-Wundef"))
-           CPP_OPTION (pfile, warn_undef) = 1;
-         else if (!strcmp (argv[i], "-Wimport"))
-           CPP_OPTION (pfile, warn_import) = 1;
-         else if (!strcmp (argv[i], "-Werror"))
-           CPP_OPTION (pfile, warnings_are_errors) = 1;
-         else if (!strcmp (argv[i], "-Wsystem-headers"))
-           CPP_OPTION (pfile, warn_system_headers) = 1;
-         else if (!strcmp (argv[i], "-Wendif-labels"))
-           CPP_OPTION (pfile, warn_endif_labels) = 1;
-         else if (!strcmp (argv[i], "-Wno-traditional"))
-           CPP_OPTION (pfile, warn_traditional) = 0;
-         else if (!strcmp (argv[i], "-Wno-trigraphs"))
-           CPP_OPTION (pfile, warn_trigraphs) = 0;
-         else if (!strcmp (argv[i], "-Wno-comment"))
-           CPP_OPTION (pfile, warn_comments) = 0;
-         else if (!strcmp (argv[i], "-Wno-comments"))
-           CPP_OPTION (pfile, warn_comments) = 0;
-         else if (!strcmp (argv[i], "-Wno-undef"))
-           CPP_OPTION (pfile, warn_undef) = 0;
-         else if (!strcmp (argv[i], "-Wno-import"))
-           CPP_OPTION (pfile, warn_import) = 0;
-         else if (!strcmp (argv[i], "-Wno-error"))
-           CPP_OPTION (pfile, warnings_are_errors) = 0;
-         else if (!strcmp (argv[i], "-Wno-system-headers"))
-           CPP_OPTION (pfile, warn_system_headers) = 0;
-         else if (!strcmp (argv[i], "-Wno-endif-labels"))
-           CPP_OPTION (pfile, warn_endif_labels) = 0;
-         else if (! ignore)
-           return i;
+
+       case OPT_Wall:
+         CPP_OPTION (pfile, warn_trigraphs) = 1;
+         CPP_OPTION (pfile, warn_comments) = 1;
+         break;
+
+       case OPT_Wtraditional:
+         CPP_OPTION (pfile, warn_traditional) = 1;
+         break;
+       case OPT_Wno_traditional:
+         CPP_OPTION (pfile, warn_traditional) = 0;
+         break;
+
+       case OPT_Wtrigraphs:
+         CPP_OPTION (pfile, warn_trigraphs) = 1;
+         break;
+       case OPT_Wno_trigraphs:
+         CPP_OPTION (pfile, warn_trigraphs) = 0;
+         break;
+
+       case OPT_Wcomment:
+       case OPT_Wcomments:
+         CPP_OPTION (pfile, warn_comments) = 1;
+         break;
+       case OPT_Wno_comment:
+       case OPT_Wno_comments:
+         CPP_OPTION (pfile, warn_comments) = 0;
+         break;
+
+       case OPT_Wundef:
+         CPP_OPTION (pfile, warn_undef) = 1;
+         break;
+       case OPT_Wno_undef:
+         CPP_OPTION (pfile, warn_undef) = 0;
+         break;
+
+       case OPT_Wimport:
+         CPP_OPTION (pfile, warn_import) = 1;
+         break;
+       case OPT_Wno_import:
+         CPP_OPTION (pfile, warn_import) = 0;
+         break;
+
+       case OPT_Wendif_labels:
+         CPP_OPTION (pfile, warn_endif_labels) = 1;
+         break;
+       case OPT_Wno_endif_labels:
+         CPP_OPTION (pfile, warn_endif_labels) = 0;
+         break;
+
+       case OPT_Werror:
+         CPP_OPTION (pfile, warnings_are_errors) = 1;
+         break;
+       case OPT_Wno_error:
+         CPP_OPTION (pfile, warnings_are_errors) = 0;
+         break;
+
+       case OPT_Wsystem_headers:
+         CPP_OPTION (pfile, warn_system_headers) = 1;
+         break;
+       case OPT_Wno_system_headers:
+         CPP_OPTION (pfile, warn_system_headers) = 0;
          break;
        }
     }
@@ -1731,7 +1757,7 @@ cpp_handle_options (pfile, argc, argv)
 
   for (i = 0; i < argc; i += strings_processed)
     {
-      strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
+      strings_processed = cpp_handle_option (pfile, argc - i, argv + i);
       if (strings_processed == 0)
        break;
     }
index 672f3e860d50e9c09558c0abba3e1551c454b88a..66a865314b4258a781996b324af33db51b9960c5 100644 (file)
@@ -515,7 +515,7 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
    structure reliable.  Options processing is not completed until you
    call cpp_finish_options.  */
 extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
-extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **, int));
+extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
 extern void cpp_post_options PARAMS ((cpp_reader *));
 
 /* This function reads the file, but does not start preprocessing.  It