aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRafael Avila de Espindola <espindola@google.com>2009-04-16 12:57:50 +0000
committerRafael Espindola <espindola@gcc.gnu.org>2009-04-16 12:57:50 +0000
commit41fd0f9b8037dba308b6ed075468a333708da228 (patch)
tree880209f07ea612d1ce7811a96cabe4898bce80b8 /gcc
parentd15d61c671cb02b6dce9d583962750875e3178e9 (diff)
downloadgcc-41fd0f9b8037dba308b6ed075468a333708da228.zip
gcc-41fd0f9b8037dba308b6ed075468a333708da228.tar.gz
gcc-41fd0f9b8037dba308b6ed075468a333708da228.tar.bz2
common.opt (fversion): New.
2009-04-16 Rafael Avila de Espindola <espindola@google.com> * common.opt (fversion): New. * gcc.c (print_version): New. (process_command): Don't print the version. Just set print_version. (main): Print version. Call subprocesses if print_version and verbose_flag are set. * opts.c (common_handle_option): Handle OPT_fversion. From-SVN: r146183
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/common.opt5
-rw-r--r--gcc/gcc.c43
-rw-r--r--gcc/opts.c1
4 files changed, 48 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2068c9c..cd6b608 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-16 Rafael Avila de Espindola <espindola@google.com>
+
+ * common.opt (fversion): New.
+ * gcc.c (print_version): New.
+ (process_command): Don't print the version. Just set print_version.
+ (main): Print version. Call subprocesses if print_version and
+ verbose_flag are set.
+ * opts.c (common_handle_option): Handle OPT_fversion.
+
2009-04-16 Richard Guenther <rguenther@suse.de>
Ira Rosen <irar@il.ibm.com>
diff --git a/gcc/common.opt b/gcc/common.opt
index f85b943..c6903b6 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -35,7 +35,7 @@ Common Report Joined
Common
Alias for --help=target
-;; The following three entries are to work around the gcc driver
+;; The following four entries are to work around the gcc driver
;; program's insatiable desire to turn options starting with a
;; double dash (--) into options starting with a dash f (-f).
fhelp
@@ -47,6 +47,9 @@ Common Joined
ftarget-help
Common
+fversion
+Common
+
-param
Common Separate
--param <param>=<value> Set parameter <param> to value. See below for a complete list of parameters
diff --git a/gcc/gcc.c b/gcc/gcc.c
index de429f8..5c697ea0 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -169,6 +169,10 @@ static int print_multi_lib;
static int print_help_list;
+/* Flag saying to print the version of gcc and its sub-processes. */
+
+static int print_version;
+
/* Flag saying to print the sysroot suffix used for searching for
headers. */
@@ -3650,14 +3654,17 @@ process_command (int argc, const char **argv)
else if (strcmp (argv[i], "-fversion") == 0)
{
/* translate_options () has turned --version into -fversion. */
- printf (_("%s %s%s\n"), programname, pkgversion_string,
- version_string);
- printf ("Copyright %s 2009 Free Software Foundation, Inc.\n",
- _("(C)"));
- fputs (_("This is free software; see the source for copying conditions. There is NO\n\
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
- stdout);
- exit (0);
+ print_version = 1;
+
+ /* We will be passing a dummy file on to the sub-processes. */
+ n_infiles++;
+ n_switches++;
+
+ /* CPP driver cannot obtain switch from cc1_options. */
+ if (is_cpp_driver)
+ add_preprocessor_option ("--version", strlen ("--version"));
+ add_assembler_option ("--version", strlen ("--version"));
+ add_linker_option ("--version", strlen ("--version"));
}
else if (strcmp (argv[i], "-fhelp") == 0)
{
@@ -4364,7 +4371,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
error ("warning: '-x %s' after last input file has no effect", spec_lang);
/* Ensure we only invoke each subprocess once. */
- if (print_subprocess_help || print_help_list)
+ if (print_subprocess_help || print_help_list || print_version)
{
n_infiles = 1;
@@ -6667,6 +6674,24 @@ main (int argc, char **argv)
fflush (stdout);
}
+ if (print_version)
+ {
+ printf (_("%s %s%s\n"), programname, pkgversion_string,
+ version_string);
+ printf ("Copyright %s 2009 Free Software Foundation, Inc.\n",
+ _("(C)"));
+ fputs (_("This is free software; see the source for copying conditions. There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
+ stdout);
+ if (! verbose_flag)
+ return 0;
+
+ /* We do not exit here. We use the same mechanism of --help to print
+ the version of the sub-processes. */
+ fputc ('\n', stdout);
+ fflush (stdout);
+ }
+
if (verbose_flag)
{
int n;
diff --git a/gcc/opts.c b/gcc/opts.c
index 5ee16d6..352ed5a 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1561,6 +1561,7 @@ common_handle_option (size_t scode, const char *arg, int value,
break;
}
+ case OPT_fversion:
case OPT__version:
print_version (stderr, "");
exit_after_options = true;