]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-common.h (enum c_language_kind): Emphasize that clk_c is 0.
authorNeil Booth <neil@gcc.gnu.org>
Sun, 11 Aug 2002 07:32:19 +0000 (07:32 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 11 Aug 2002 07:32:19 +0000 (07:32 +0000)
* c-common.h (enum c_language_kind): Emphasize that clk_c is 0.
* c-opts.c (parse_option): Rename find_opt.
(set_std_c99): New function.
(COMMAND_LINE_OPTIONS): Handle -remap and -o.  Remove OPT_std_bad.
(missing_arg): Remove OPT_std_bad.  Handle -o.
(c_common_decode_option): Handle input and output file names,
-o and -remap. Clean up -std= handling.
* cppinit.c (COMMAND_LINE_OPTIONS): Remove OPT_o and OPT_remap.
(cpp_handle_option): Similarly.  Don't handle filenames.

From-SVN: r56197

gcc/c-common.h
gcc/c-opts.c
gcc/cppinit.c

index 63a6837e29d40a930a9596f872fa2f12b9aa520b..989c90810b74cb20f5f2aab278b3138f19f6f1b0 100644 (file)
@@ -238,8 +238,7 @@ extern GTY(()) tree c_global_trees[CTI_MAX];
 
 typedef enum c_language_kind
 {
-  clk_c,           /* A dialect of C: K&R C, ANSI/ISO C89, C2000,
-                      etc.  */
+  clk_c = 0,      /* A dialect of C: K&R C, ANSI/ISO C89, C2000, etc.  */
   clk_cplusplus   /* ANSI/ISO C++ */
 }
 c_language_kind;
index e6274d86f8efb6eac6b5382c05ffdd736ce6f430..d25c9971c66054bfcb3f27a7307c3ea867c4f9f3 100644 (file)
@@ -34,7 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 static cpp_options *cpp_opts;
 
 static void missing_arg PARAMS ((size_t));
-static size_t parse_option PARAMS ((const char *, int));
+static size_t find_opt PARAMS ((const char *, int));
 static void set_Wimplicit PARAMS ((int));
 static void complain_wrong_lang PARAMS ((size_t));
 static void write_langs PARAMS ((char *, int));
@@ -42,6 +42,7 @@ static void print_help PARAMS ((void));
 static void handle_OPT_d PARAMS ((const char *));
 static void set_std_cxx98 PARAMS ((int));
 static void set_std_c89 PARAMS ((int, int));
+static void set_std_c99 PARAMS ((int));
 
 #define CL_C_ONLY      (1 << 0) /* Only C.  */
 #define CL_OBJC_ONLY   (1 << 1) /* Only ObjC.  */
@@ -216,10 +217,11 @@ static void set_std_c89 PARAMS ((int, int));
   OPT("lang-objc",              CL_ALL,   OPT_lang_objc)                    \
   OPT("nostdinc",               CL_ALL,   OPT_nostdinc)                             \
   OPT("nostdinc++",             CL_ALL,   OPT_nostdincplusplus)                     \
+  OPT("o",                     CL_ALL | CL_ARG, OPT_o)                      \
   OPT("pedantic",              CL_ALL,   OPT_pedantic)                      \
   OPT("pedantic-errors",       CL_ALL,   OPT_pedantic_errors)               \
   OPT("print-objc-runtime-info", CL_OBJC, OPT_print_objc_runtime_info)      \
-  OPT("std=",                  CL_ALL | CL_JOINED, OPT_std_bad)             \
+  OPT("remap",                 CL_ALL,   OPT_remap)                         \
   OPT("std=c++98",             CL_CXX,   OPT_std_cplusplus98)               \
   OPT("std=c89",               CL_C,     OPT_std_c89)                       \
   OPT("std=c99",               CL_C,     OPT_std_c99)                       \
@@ -294,7 +296,6 @@ missing_arg (opt_index)
     case OPT_fname_mangling:
     case OPT_ftabstop:
     case OPT_ftemplate_depth:
-    case OPT_std_bad:
     default:
       error ("missing argument to \"-%s\"", cl_options[opt_index].opt_text);
       break;
@@ -302,6 +303,10 @@ missing_arg (opt_index)
     case OPT_fconstant_string_class:
       error ("no class name specified with -fconstant-string-class=");
       break;
+
+    case OPT_o:
+      error ("missing filename after \"-%s\"", cl_options[opt_index].opt_text);
+      break;
     }
 }
 
@@ -314,7 +319,7 @@ missing_arg (opt_index)
    and -pedantic-errors.  Also, some options are only accepted by some
    languages.  */
 static size_t
-parse_option (input, lang_flag)
+find_opt (input, lang_flag)
      const char *input;
      int lang_flag;
 {
@@ -435,32 +440,32 @@ c_common_decode_option (argc, argv)
      int argc;
      char **argv;
 {
+  static int lang_flags[] = {CL_C_ONLY, CL_C, CL_CXX_ONLY, CL_CXX};
   size_t opt_index;
   const char *opt, *arg = 0;
   char *dup = 0;
   bool on = true;
-  int result, lang_flag;
+  int result;
   const struct cl_option *option;
   enum opt_code code;
 
-  result = cpp_handle_option (parse_in, argc, argv);
   opt = argv[0];
 
-  /* Until handling CPP stuff, ignore non-switches.  */
+  /* Interpret "-" or a non-switch as a file name.  */
   if (opt[0] != '-' || opt[1] == '\0')
-    return result;
-
-  switch (c_language)
     {
-    case clk_c:                        lang_flag = (flag_objc
-                                            ? CL_C
-                                            : CL_C_ONLY);
-                               break;
-    case clk_cplusplus:                lang_flag = (flag_objc
-                                            ? CL_CXX
-                                            : CL_CXX_ONLY);
-                               break;
-    default:                   abort ();
+      if (!cpp_opts->in_fname)
+       cpp_opts->in_fname = opt;
+      else if (!cpp_opts->out_fname)
+       cpp_opts->out_fname = opt;
+      else
+       {
+         error ("too many filenames given.  Type %s --help for usage",
+                progname);
+         return argc;
+       }
+
+      return 1;
     }
 
   /* Drop the "no-" from negative switches.  */
@@ -477,8 +482,10 @@ c_common_decode_option (argc, argv)
       on = false;
     }
 
+  result = cpp_handle_option (parse_in, argc, argv);
+
   /* Skip over '-'.  */
-  opt_index = parse_option (opt + 1, lang_flag);
+  opt_index = find_opt (opt + 1, lang_flags[(c_language << 1) + flag_objc]);
   if (opt_index == N_OPTS)
     goto done;
 
@@ -1102,6 +1109,16 @@ c_common_decode_option (argc, argv)
       cpp_opts->no_standard_cplusplus_includes = 1;
       break;
 
+    case OPT_o:
+      if (!cpp_opts->out_fname)
+       cpp_opts->out_fname = arg;
+      else
+       {
+         error ("output filename specified twice");
+         result = argc;
+       }
+      break;
+
       /* We need to handle the -pedantic switches here, rather than in
         c_common_post_options, so that a subsequent -Wno-endif-labels
         is not overridden.  */
@@ -1117,29 +1134,19 @@ c_common_decode_option (argc, argv)
       print_struct_values = 1;
       break;
 
-    case OPT_std_bad:
-      error ("unknown standard \"%s\"", arg);
+    case OPT_remap:
+      cpp_opts->remap = 1;
       break;
 
-      /* Language standards.  We currently recognize:
-        -std=iso9899:1990      same as -ansi
-        -std=iso9899:199409    ISO C as modified in amend. 1
-        -std=iso9899:1999      ISO C 99
-        -std=c89               same as -std=iso9899:1990
-        -std=c99               same as -std=iso9899:1999
-        -std=gnu89             default, iso9899:1990 + gnu extensions
-        -std=gnu99             iso9899:1999 + gnu extensions
-      */
-
     case OPT_std_cplusplus98:
     case OPT_std_gnuplusplus98:
-      set_std_cxx98 (code == OPT_std_cplusplus98);
+      set_std_cxx98 (code == OPT_std_cplusplus98 /* ISO */);
       break;
 
-    case OPT_std_iso9899_199409:
     case OPT_std_c89:
     case OPT_std_iso9899_1990:
-      set_std_c89 (code == OPT_std_iso9899_199409, true);
+    case OPT_std_iso9899_199409:
+      set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
       break;
 
     case OPT_std_gnu89:
@@ -1150,25 +1157,12 @@ c_common_decode_option (argc, argv)
     case OPT_std_c9x:
     case OPT_std_iso9899_1999:
     case OPT_std_iso9899_199x:
-      cpp_set_lang (parse_in, CLK_STDC99);
-      flag_writable_strings = 0;
-      flag_no_asm = 1;
-      flag_no_nonansi_builtin = 1;
-      flag_noniso_default_format_attributes = 0;
-      flag_isoc99 = 1;
-      flag_isoc94 = 1;
-      flag_iso = 1;
+      set_std_c99 (true /* ISO */);
       break;
 
     case OPT_std_gnu99:
     case OPT_std_gnu9x:
-      cpp_set_lang (parse_in, CLK_GNUC99);
-      flag_writable_strings = 0;
-      flag_no_asm = 0;
-      flag_no_nonansi_builtin = 0;
-      flag_noniso_default_format_attributes = 1;
-      flag_isoc99 = 1;
-      flag_isoc94 = 1;
+      set_std_c99 (false /* ISO */);
       break;
 
     case OPT_trigraphs:
@@ -1246,7 +1240,7 @@ c_common_post_options ()
 }
 
 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
-   extensions if ISO).  */
+   extensions if ISO).  There is no concept of gnu94.  */
 static void
 set_std_c89 (c94, iso)
      int c94, iso;
@@ -1262,6 +1256,21 @@ set_std_c89 (c94, iso)
   flag_writable_strings = 0;
 }
 
+/* Set the C 99 standard (without GNU extensions if ISO).  */
+static void
+set_std_c99 (iso)
+     int iso;
+{
+  cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
+  flag_no_asm = iso;
+  flag_no_nonansi_builtin = iso;
+  flag_noniso_default_format_attributes = !iso;
+  flag_iso = iso;
+  flag_isoc99 = 1;
+  flag_isoc94 = 1;
+  flag_writable_strings = 0;
+}
+
 /* Set the C++ 98 standard (without GNU extensions if ISO).  */
 static void
 set_std_cxx98 (iso)
index 927311e0a022116102c1154a1c3f2995ac6d23f1..86b4c8eef3acdaf460ab6532db0a3eead358a4fe 100644 (file)
@@ -1151,9 +1151,7 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("iprefix",                  no_pth, OPT_iprefix)                    \
   DEF_OPT("isystem",                  no_dir, OPT_isystem)                    \
   DEF_OPT("iwithprefix",              no_dir, OPT_iwithprefix)                \
-  DEF_OPT("iwithprefixbefore",        no_dir, OPT_iwithprefixbefore)          \
-  DEF_OPT("o",                        no_fil, OPT_o)                          \
-  DEF_OPT("remap",                    0,      OPT_remap)
+  DEF_OPT("iwithprefixbefore",        no_dir, OPT_iwithprefixbefore)
 
 #define DEF_OPT(text, msg, code) code,
 enum opt_code
@@ -1256,19 +1254,6 @@ cpp_handle_option (pfile, argc, argv)
   int i = 0;
   struct cpp_pending *pend = CPP_OPTION (pfile, pending);
 
-  /* Interpret "-" or a non-option as a file name.  */
-  if (argv[i][0] != '-' || argv[i][1] == '\0')
-    {
-      if (CPP_OPTION (pfile, in_fname) == NULL)
-       CPP_OPTION (pfile, in_fname) = argv[i];
-      else if (CPP_OPTION (pfile, out_fname) == NULL)
-       CPP_OPTION (pfile, out_fname) = argv[i];
-      else
-       cpp_error (pfile, DL_ERROR,
-                  "too many filenames. Type %s --help for usage info",
-                  progname);
-    }
-  else
     {
       enum opt_code opt_code;
       int opt_index;
@@ -1303,22 +1288,10 @@ cpp_handle_option (pfile, argc, argv)
        case OPT_D:
          new_pending_directive (pend, arg, cpp_define);
          break;
-       case OPT_remap:
-         CPP_OPTION (pfile, remap) = 1;
-         break;
        case OPT_iprefix:
          CPP_OPTION (pfile, include_prefix) = arg;
          CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
          break;
-       case OPT_o:
-         if (CPP_OPTION (pfile, out_fname) == NULL)
-           CPP_OPTION (pfile, out_fname) = arg;
-         else
-           {
-             cpp_error (pfile, DL_ERROR, "output filename specified twice");
-             return argc;
-           }
-         break;
 
        case OPT_MG:
          CPP_OPTION (pfile, print_deps_missing_files) = 1;