]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-common.h (c_comon_handle_filename, [...]): New.
authorNeil Booth <neil@daikokuya.co.uk>
Sun, 6 Jul 2003 19:01:21 +0000 (19:01 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 6 Jul 2003 19:01:21 +0000 (19:01 +0000)
* c-common.h (c_comon_handle_filename,
c_common_missing_arguement): New.
* c-lang.c (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): New.
* c-opts.c (missing_arg): Rename c_common_missing_argument,
update to be an appropriate langhook.
(c_common_handle_option): Don't handle filenames.
(c_common_handle_filename): New.
* hooks.c (hook_void_constcharptr,
hook_bool_constcharptr_size_t_false): New.
* hooks.h (hook_void_constcharptr,
hook_bool_constcharptr_size_t_false): New.
* langhooks-def.h (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): New.
(LANG_HOOKS_INITIALIZER): Update.
* langhooks.h (struct lang_hooks): Add handle_filename and
missing_argument.
* opts.c (handle_option): Don't handle filenames here, but ...
(handle_options): ... here.
(common_handle_option): Don't handle missing arguments here.
* objc/objc-lang.c (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): New.
ada:
* misc.c (gnat_handle_option): Don't handle filenames.
cp:
* cp-lang.c (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): Override.
f:
* top.c (ffe_handle_option): Don't handle filenames.
java:
* lang.c (java_handle_option): Don't handle filenames.

From-SVN: r69011

18 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/misc.c
gcc/c-common.h
gcc/c-lang.c
gcc/c-opts.c
gcc/cp/ChangeLog
gcc/cp/cp-lang.c
gcc/f/ChangeLog
gcc/f/top.c
gcc/hooks.c
gcc/hooks.h
gcc/java/ChangeLog
gcc/java/lang.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/objc/objc-lang.c
gcc/opts.c

index e0c44ebaa51cdc3d73d2e588741a227bf3d5286b..c93c75031497d32e3dcdefd4ce0ffcf2c5e3f4a1 100644 (file)
@@ -1,3 +1,28 @@
+2003-07-06  Neil Booth  <neil@daikokuya.co.uk>
+
+       * c-common.h (c_comon_handle_filename,
+       c_common_missing_arguement): New.
+       * c-lang.c (LANG_HOOKS_HANDLE_FILENAME,
+       LANG_HOOKS_MISSING_ARGUMENT): New.
+       * c-opts.c (missing_arg): Rename c_common_missing_argument,
+       update to be an appropriate langhook.
+       (c_common_handle_option): Don't handle filenames.
+       (c_common_handle_filename): New.
+       * hooks.c (hook_void_constcharptr,
+       hook_bool_constcharptr_size_t_false): New.
+       * hooks.h (hook_void_constcharptr,
+       hook_bool_constcharptr_size_t_false): New.
+       * langhooks-def.h (LANG_HOOKS_HANDLE_FILENAME,
+       LANG_HOOKS_MISSING_ARGUMENT): New.
+       (LANG_HOOKS_INITIALIZER): Update.
+       * langhooks.h (struct lang_hooks): Add handle_filename and
+       missing_argument.
+       * opts.c (handle_option): Don't handle filenames here, but ...
+       (handle_options): ... here.
+       (common_handle_option): Don't handle missing arguments here.
+       * objc/objc-lang.c (LANG_HOOKS_HANDLE_FILENAME,
+       LANG_HOOKS_MISSING_ARGUMENT): New.
+
 2003-07-06  Neil Booth  <neil@daikokuya.co.uk>
 
        * Makfile.in: Remove traces of mbchar.
index 53916bbd0e331b807a4bb27dd049882f4ee4b249..467111fa1c89123834fe0866d3aff059fd5bc340 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-06  Neil Booth  <neil@daikokuya.co.uk>
+
+       * misc.c (gnat_handle_option): Don't handle filenames.
+
 2003-07-04  H.J. Lu <hongjiu.lu@intel.com>
 
        * Make-lang.in: Replace PWD with PWD_COMMAND.
index ca9a036149256915ec68c15c83d4c6e7e39d7211..60232bf59970f3b9d1b5ad6e27ba30e75ab040f5 100644 (file)
@@ -226,10 +226,6 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED)
   char *q;
   unsigned int i;
 
-  /* Ignore file names.  */
-  if (code == N_OPTS)
-      return 1;
-
   switch (code)
     {
     default:
index d1c3e5a0fff44cf9dcec0386f2e097f0059933ed..bafe85709004d8446d98ccde003bee4919f402f7 100644 (file)
@@ -896,6 +896,8 @@ extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
 extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
 extern void c_common_insert_default_attributes (tree);
 extern int c_common_handle_option (size_t code, const char *arg, int value);
+extern void c_common_handle_filename (const char *filename);
+extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
 extern tree c_common_type_for_size (unsigned int, int);
 extern tree c_common_unsigned_type (tree);
index 5da15e5fa3c1609e46867e7d2063f7ea0fdf6bdd..99b01ec82a283ca4451dd4850a94a8dfe565c112 100644 (file)
@@ -45,6 +45,10 @@ enum c_language_kind c_language = clk_c;
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
+#undef LANG_HOOKS_HANDLE_FILENAME
+#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
+#undef LANG_HOOKS_MISSING_ARGUMENT
+#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
 #undef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
index 3bccc7e0c93fff7e0d7f16056e46a4f52ee78109..063e6e208c36728d87b1dbaf0c021e4ffc0f822d 100644 (file)
@@ -97,7 +97,6 @@ static size_t include_cursor;
 /* Permit Fotran front-end options.  */
 static bool permit_fortran_options;
 
-void missing_arg (enum opt_code);
 static void set_Wimplicit (int);
 static void print_help (void);
 static void handle_OPT_d (const char *);
@@ -125,51 +124,37 @@ static struct deferred_opt
   const char *arg;
 } *deferred_opts;
 
-/* Complain that switch OPT_INDEX expects an argument but none was
-   provided.  */
-void
-missing_arg (enum opt_code code)
+/* Complain that switch CODE expects an argument but none was
+   provided.  OPT was the command-line option.  Return FALSE to get
+   the default message in opts.c, TRUE if we provide a specialized
+   one.  */
+bool
+c_common_missing_argument (const char *opt, size_t code)
 {
-  const char *opt_text = cl_options[code].opt_text;
-
   switch (code)
     {
-    case OPT__output_pch_:
-    case OPT_Wformat_:
-    case OPT_d:
-    case OPT_fabi_version_:
-    case OPT_fbuiltin_:
-    case OPT_fdump_:
-    case OPT_fname_mangling_version_:
-    case OPT_ftabstop_:
-    case OPT_fexec_charset_:
-    case OPT_fwide_exec_charset_:
-    case OPT_ftemplate_depth_:
-    case OPT_iprefix:
-    case OPT_iwithprefix:
-    case OPT_iwithprefixbefore:
     default:
-      error ("missing argument to \"-%s\"", opt_text);
-      break;
+      /* Pick up the default message.  */
+      return false;
 
     case OPT_fconstant_string_class_:
-      error ("no class name specified with \"-%s\"", opt_text);
+      error ("no class name specified with \"%s\"", opt);
       break;
 
     case OPT_A:
-      error ("assertion missing after \"-%s\"", opt_text);
+      error ("assertion missing after \"%s\"", opt);
       break;
 
     case OPT_D:
     case OPT_U:
-      error ("macro name missing after \"-%s\"", opt_text);
+      error ("macro name missing after \"%s\"", opt);
       break;
 
     case OPT_I:
     case OPT_idirafter:
     case OPT_isysroot:
     case OPT_isystem:
-      error ("missing path after \"-%s\"", opt_text);
+      error ("missing path after \"%s\"", opt);
       break;
 
     case OPT_MF:
@@ -178,14 +163,16 @@ missing_arg (enum opt_code code)
     case OPT_include:
     case OPT_imacros:
     case OPT_o:
-      error ("missing filename after \"-%s\"", opt_text);
+      error ("missing filename after \"%s\"", opt);
       break;
 
     case OPT_MQ:
     case OPT_MT:
-      error ("missing target after \"-%s\"", opt_text);
+      error ("missing makefile target after \"%s\"", opt);
       break;
     }
+
+  return true;
 }
 
 /* Defer option CODE with argument ARG.  */
@@ -261,18 +248,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
   enum opt_code code = (enum opt_code) scode;
   int result = 1;
 
-  if (code == N_OPTS)
-    {
-      if (!in_fname)
-       in_fname = arg;
-      else if (!out_fname)
-       out_fname = arg;
-      else
-         error ("too many filenames given.  Type %s --help for usage",
-                progname);
-      return 1;
-    }
-
   switch (code)
     {
     default:
@@ -700,7 +675,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
     case OPT_fthis_is_variable:
     case OPT_fvtable_thunks:
     case OPT_fxref:
-      warning ("switch \"%s\" is no longer supported", option->opt_text);
+      warning ("switch \"-%s\" is no longer supported", option->opt_text);
       break;
 
     case OPT_fabi_version_:
@@ -716,7 +691,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       if (value)
        flag_external_templates = true;
     cp_deprecated:
-      warning ("switch \"%s\" is deprecated, please see documentation for details", option->opt_text);
+      warning ("switch \"-%s\" is deprecated, please see documentation "
+              "for details", option->opt_text);
       break;
 
     case OPT_fasm:
@@ -1059,6 +1035,18 @@ c_common_handle_option (size_t scode, const char *arg, int value)
   return result;
 }
 
+/* Handle FILENAME from the command line.  */
+void
+c_common_handle_filename (const char *filename)
+{
+  if (!in_fname)
+    in_fname = filename;
+  else if (!out_fname)
+    out_fname = filename;
+  else
+    error ("output filename specified twice");
+}
+
 /* Post-switch processing.  */
 bool
 c_common_post_options (const char **pfilename)
index 62d989d89a8399835aa5753034b4c6d7a0ebac1b..63227de4945005b2cd0691ac9f49eb53538b2bc0 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-06  Neil Booth  <neil@daikokuya.co.uk>
+
+       * cp-lang.c (LANG_HOOKS_HANDLE_FILENAME,
+       LANG_HOOKS_MISSING_ARGUMENT): Override.
+
 2003-07-05  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/11431
index 78a4e6ba3e38602eace9c690f01313619aeb26b5..affc964664065db4ae8a91a9bdea98f77f7fa038 100644 (file)
@@ -53,6 +53,10 @@ static bool cp_var_mod_type_p (tree);
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
+#undef LANG_HOOKS_HANDLE_FILENAME
+#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
+#undef LANG_HOOKS_MISSING_ARGUMENT
+#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
 #undef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
index 1203559edbab4ae462421eb40170314267dd9367..34483fe06ffb919b69be5caa5b0d1fc98dfd5dae 100644 (file)
@@ -1,3 +1,7 @@
+Sun Jul  6 20:01:29 2003  Neil Booth  <neil@daikokuya.co.uk>
+
+       * top.c (ffe_handle_option): Don't handle filenames.
+
 2003-07-05  Toon Moene  <toon@moene.indiv.nluug.nl>
 
        PR Fortran/11301
index 30b6eb21f8c2961def7429c45e9b9d955f24477b..81d6c68988fff569347a78c3be717ede0abd0863 100644 (file)
@@ -178,10 +178,6 @@ ffe_handle_option (size_t scode, const char *arg, int value)
 {
   enum opt_code code = (enum opt_code) scode;
 
-  /* Ignore file names.  */
-  if (code == N_OPTS)
-    return 1;
-
   switch (code)
     {
     default:
index d737000620b533e32b8b876994f6935d2d5f0b2a..c022eb38853432ba096f56fba5b188879103895b 100644 (file)
@@ -68,6 +68,11 @@ hook_void_FILEptr_constcharptr (FILE *a ATTRIBUTE_UNUSED, const char *b ATTRIBUT
 {
 }
 
+void
+hook_void_constcharptr (const char *a ATTRIBUTE_UNUSED)
+{
+}
+
 /* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook.  */
 bool
 hook_bool_tree_hwi_hwi_tree_false (tree a ATTRIBUTE_UNUSED,
@@ -87,6 +92,13 @@ hook_bool_tree_hwi_hwi_tree_true (tree a ATTRIBUTE_UNUSED,
   return true;
 }
 
+bool
+hook_bool_constcharptr_size_t_false (const char *a ATTRIBUTE_UNUSED,
+                                    size_t b ATTRIBUTE_UNUSED)
+{
+  return false;
+}
+
 bool
 default_can_output_mi_thunk_no_vcall (tree a ATTRIBUTE_UNUSED,
                                      HOST_WIDE_INT b ATTRIBUTE_UNUSED,
index 4309a5dca7235a3df0b607207f20d929ed7cc2d4..6fa0bbec3c35d1d1095cbf44afb2cf223f7c7fbb 100644 (file)
@@ -31,12 +31,14 @@ bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT,
                                       tree);
 bool hook_bool_rtx_false (rtx);
 bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *);
+bool hook_bool_constcharptr_size_t_false (const char *, size_t);
 
 void hook_void_tree_int (tree, int);
 void hook_void_void (void);
 void hook_void_FILEptr_constcharptr (FILE *, const char *);
 void hook_void_tree (tree);
 void hook_void_tree_treeptr (tree, tree *);
+void hook_void_constcharptr (const char *);
 
 int hook_int_tree_tree_1 (tree, tree);
 int hook_int_rtx_0 (rtx);
index db3a7b0b724d747a52b03ae85e063ee68e092295..8627d269dc435105cfd254f4fb41dbffeaed7788 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-06  Neil Booth  <neil@daikokuya.co.uk>
+
+       * lang.c (java_handle_option): Don't handle filenames.
+
 2003-07-02  Zack Weinberg  <zack@codesourcery.com>
 
        * jcf-path.c: Don't default-define PATH_SEPARATOR nor
index 7137bcffd5817eedda924212d87c209c7584be33..7402ab7f086ce6c859107813c8fa58dc3ed64606 100644 (file)
@@ -267,10 +267,6 @@ java_handle_option (size_t scode, const char *arg, int value)
 {
   enum opt_code code = (enum opt_code) scode;
 
-  /* Ignore file names.  */
-  if (code == N_OPTS)
-      return 1;
-
   switch (code)
     {
     default:
index 4995d4a61a15bb3ec064262248e7113367afe4b3..a598c05114e2ac2e861c2ffb3346e50c48064774 100644 (file)
@@ -90,6 +90,8 @@ extern void write_global_declarations (void);
 #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack
 #define LANG_HOOKS_INIT_OPTIONS                hook_uint_uint_constcharptrptr_0
 #define LANG_HOOKS_HANDLE_OPTION       hook_int_size_t_constcharptr_int_0
+#define LANG_HOOKS_HANDLE_FILENAME     hook_void_constcharptr
+#define LANG_HOOKS_MISSING_ARGUMENT    hook_bool_constcharptr_size_t_false
 #define LANG_HOOKS_POST_OPTIONS                lhd_post_options
 #define LANG_HOOKS_GET_ALIAS_SET       lhd_get_alias_set
 #define LANG_HOOKS_EXPAND_CONSTANT     lhd_return_tree
@@ -244,6 +246,8 @@ extern int lhd_tree_dump_type_quals (tree);
   LANG_HOOKS_TREE_SIZE, \
   LANG_HOOKS_INIT_OPTIONS, \
   LANG_HOOKS_HANDLE_OPTION, \
+  LANG_HOOKS_HANDLE_FILENAME, \
+  LANG_HOOKS_MISSING_ARGUMENT, \
   LANG_HOOKS_POST_OPTIONS, \
   LANG_HOOKS_INIT, \
   LANG_HOOKS_FINISH, \
index df3dab1587dcc4c57bd45129e0d458342ea28a6b..1ba3bfe3743e504071c0ca081e670bb9dd32af86 100644 (file)
@@ -217,6 +217,13 @@ struct lang_hooks
      valid and should not be treated as language-independent too.  */
   int (*handle_option) (size_t code, const char *arg, int value);
 
+  /* Handle a filename on the command line.  */
+  void (*handle_filename) (const char *filename);
+
+  /* Return false to use the default complaint about a missing
+     argument, otherwise output a complaint and return true.  */
+  bool (*missing_argument) (const char *opt, size_t code);
+
   /* Called when all command line options have been parsed to allow
      further processing and initialization
 
index 4457ee84ceb1bbd3c4e06a6678e8e6d9e3b3bc89..99e3967e1c8e7b24d052e045edc18a07424440c1 100644 (file)
@@ -43,6 +43,10 @@ enum c_language_kind c_language = clk_objc;
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
+#undef LANG_HOOKS_HANDLE_FILENAME
+#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
+#undef LANG_HOOKS_MISSING_ARGUMENT
+#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
 #undef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
index 626dc5aa662479aeaff5f332f72d293de03a2c21..f3889c77a1ac7d4d2a286f319abe7a1d163ea0fd 100644 (file)
@@ -297,106 +297,96 @@ handle_option (const char **argv, unsigned int lang_mask)
 
   opt = argv[0];
 
-  /* Interpret "-" or a non-switch as a file name.  */
-  if (opt[0] != '-' || opt[1] == '\0')
+  /* Drop the "no-" from negative switches.  */
+  if ((opt[1] == 'W' || opt[1] == 'f')
+      && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
     {
-      opt_index = cl_options_count;
-      arg = opt;
-      main_input_filename = opt;
-      result = (*lang_hooks.handle_option) (opt_index, arg, value);
+      size_t len = strlen (opt) - 3;
+
+      dup = xmalloc (len + 1);
+      dup[0] = '-';
+      dup[1] = opt[1];
+      memcpy (dup + 2, opt + 5, len - 2 + 1);
+      opt = dup;
+      value = 0;
     }
-  else
-    {
-      /* Drop the "no-" from negative switches.  */
-      if ((opt[1] == 'W' || opt[1] == 'f')
-         && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
-       {
-         size_t len = strlen (opt) - 3;
-
-         dup = xmalloc (len + 1);
-         dup[0] = '-';
-         dup[1] = opt[1];
-         memcpy (dup + 2, opt + 5, len - 2 + 1);
-         opt = dup;
-         value = 0;
-       }
 
-      opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
-      if (opt_index == cl_options_count)
-       goto done;
+  opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
+  if (opt_index == cl_options_count)
+    goto done;
 
-      option = &cl_options[opt_index];
+  option = &cl_options[opt_index];
 
-      /* Reject negative form of switches that don't take negatives as
-        unrecognized.  */
-      if (!value && (option->flags & CL_REJECT_NEGATIVE))
-       goto done;
+  /* Reject negative form of switches that don't take negatives as
+     unrecognized.  */
+  if (!value && (option->flags & CL_REJECT_NEGATIVE))
+    goto done;
 
-      /* We've recognized this switch.  */
-      result = 1;
+  /* We've recognized this switch.  */
+  result = 1;
 
-      /* Sort out any argument the switch takes.  */
-      if (option->flags & CL_JOINED)
+  /* Sort out any argument the switch takes.  */
+  if (option->flags & CL_JOINED)
+    {
+      /* Have arg point to the original switch.  This is because
+        some code, such as disable_builtin_function, expects its
+        argument to be persistent until the program exits.  */
+      arg = argv[0] + cl_options[opt_index].opt_len + 1;
+      if (!value)
+       arg += strlen ("no-");
+
+      if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
        {
-         /* Have arg point to the original switch.  This is because
-            some code, such as disable_builtin_function, expects its
-            argument to be persistent until the program exits.  */
-         arg = argv[0] + cl_options[opt_index].opt_len + 1;
-         if (!value)
-           arg += strlen ("no-");
-
-         if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
+         if (option->flags & CL_SEPARATE)
            {
-             if (option->flags & CL_SEPARATE)
-               {
-                 arg = argv[1];
-                 result = 2;
-               }
-             else
-               /* Missing argument.  */
-               arg = NULL;
+             arg = argv[1];
+             result = 2;
            }
+         else
+           /* Missing argument.  */
+           arg = NULL;
        }
-      else if (option->flags & CL_SEPARATE)
-       {
-         arg = argv[1];
-         result = 2;
-       }
+    }
+  else if (option->flags & CL_SEPARATE)
+    {
+      arg = argv[1];
+      result = 2;
+    }
 
-      /* Now we've swallowed any potential argument, complain if this
-        is a switch for a different front end.  */
-      if (!(option->flags & (lang_mask | CL_COMMON)))
-       {
-         complain_wrong_lang (argv[0], option, lang_mask);
-         goto done;
-       }
+  /* Now we've swallowed any potential argument, complain if this
+     is a switch for a different front end.  */
+  if (!(option->flags & (lang_mask | CL_COMMON)))
+    {
+      complain_wrong_lang (argv[0], option, lang_mask);
+      goto done;
+    }
 
-      if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
-       {
-         error ("missing argument to \"-%s\"", argv[0]);
-         goto done;
-       }
+  if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
+    {
+      if (!(*lang_hooks.missing_argument) (opt, opt_index))
+       error ("missing argument to \"%s\"", opt);
+      goto done;
+    }
 
-      /* If the switch takes an integer, convert it.  */
-      if (arg && (option->flags & CL_UINTEGER))
+  /* If the switch takes an integer, convert it.  */
+  if (arg && (option->flags & CL_UINTEGER))
+    {
+      value = integral_argument (arg);
+      if (value == -1)
        {
-         value = integral_argument (arg);
-         if (value == -1)
-           {
-             error ("argument to \"-%s\" should be a non-negative integer",
-                    option->opt_text);
-             goto done;
-           }
+         error ("argument to \"-%s\" should be a non-negative integer",
+                option->opt_text);
+         goto done;
        }
+    }
 
-      if (option->flags & lang_mask)
-       if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0)
-         result = 0;
+  if (option->flags & lang_mask)
+    if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0)
+      result = 0;
 
-      if (result && (option->flags & CL_COMMON))
-       if (common_handle_option (opt_index, arg, value) == 0)
-         result = 0;
-    }
+  if (result && (option->flags & CL_COMMON))
+    if (common_handle_option (opt_index, arg, value) == 0)
+      result = 0;
 
  done:
   if (dup)
@@ -414,12 +404,23 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
 
   for (i = 1; i < argc; i += n)
     {
+      const char *opt = argv[i];
+
+      /* Interpret "-" or a non-switch as a file name.  */
+      if (opt[0] != '-' || opt[1] == '\0')
+       {
+         main_input_filename = opt;
+         (*lang_hooks.handle_filename) (opt);
+         n = 1;
+         continue;
+       }
+
       n = handle_option (argv + i, lang_mask);
 
       if (!n)
        {
          n = 1;
-         error ("unrecognized command line option \"%s\"", argv[i]);
+         error ("unrecognized command line option \"%s\"", opt);
        }
     }
 }
@@ -603,15 +604,8 @@ static int
 common_handle_option (size_t scode, const char *arg,
                      int value ATTRIBUTE_UNUSED)
 {
-  const struct cl_option *option = &cl_options[scode];
   enum opt_code code = (enum opt_code) scode;
 
-  if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
-    {
-      error ("missing argument to \"-%s\"", option->opt_text);
-      return 1;
-    }
-
   switch (code)
     {
     default: