diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-22 20:12:06 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-22 20:12:06 +0000 |
commit | 5789e05bf0e84052ed8a54b0cd695725f3dfa2ce (patch) | |
tree | c66d31c60ecaae93e312d12451c889cde531ce79 | |
parent | 6c810f5b4a869e0ed1939f4c8ded625bb7e445da (diff) | |
download | gcc-5789e05bf0e84052ed8a54b0cd695725f3dfa2ce.tar.gz |
* common.opt (-assemble, -compile, -coverage, -debug, -dump,
-dump=, -dumpbase, -dumpdir, -entry, -entry=, -extra-warnings,
-for-assembler, -for-assembler=, -for-linker, -for-linker=,
-force-link, -force-link=, -language, -language=,
-library-directory, -library-directory=, -no-canonical-prefixes,
-no-standard-libraries, -no-warnings, -optimize, -output,
-output=, -pass-exit-codes, -pedantic, -pedantic-errors, -pie,
-pipe, -prefix, -prefix=, -preprocess, -print-file-name,
-print-file-name=, -print-libgcc-file-name,
-print-multi-directory, -print-multi-lib,
-print-multi-os-directory, -print-prog-name, -print-prog-name=,
-print-search-dirs, -print-sysroot, -print-sysroot-headers-suffix,
-profile, -save-temps, -shared, -specs, -specs=, -static,
-symbolic, -time, -verbose, -param=, -sysroot, coverage, e, u,
symbolic): New.
(fhelp, fhelp=, ftarget-help, fversion): Make into aliases.
* gcc.c (A Short Introduction to Adding a Command-Line Option):
Remove comment.
(cc1_options): Correct specs for passing down --help,
--target-help and --help=*. Add spec for passing down --version.
(struct option_map, option_map, target_option_translations,
translate_options): Remove.
(driver_handle_option): Handle OPT__version, OPT__help, OPT__help_
and OPT__target_help instead of OPT_fversion, OPT_fhelp,
OPT_fhelp_ and OPT_ftarget_help.
(process_command): Don't call translate_options. Call
decode_cmdline_options_to_array before checking for
-no-canonical-prefixes using decoded options.
* opts-common.c (tm.h): Update comment on #include.
(find_opt): Allow abbreviations of long options.
(struct option_map, option_map): New.
(decode_cmdline_option): Use them instead of hardcoding -Wno, -fno
and -mno handling.
(target_option_translations): New.
(decode_cmdline_options_to_array): Handle
TARGET_OPTION_TRANSLATE_TABLE in driver.
* opts.c (common_handle_option): Don't handle OPT_fhelp,
OPT_ftarget_help, OPT_fhelp_ or OPT_fversion.
ada:
* gcc-interface/lang.opt (-all-warnings, -include-barrier,
-include-directory, -include-directory=, -no-standard-includes,
-no-standard-libraries): New.
c-family:
* c.opt (-all-warnings, -ansi, -assert, -assert=, -comments,
-comments-in-macros, -define-macro, -define-macro=, -dependencies,
-dump, -dump=, -imacros, -imacros=, -include, -include=,
-include-barrier, -include-directory, -include-directory=,
-include-directory-after, -include-directory-after=,
-include-prefix, -include-prefix=, -include-with-prefix,
-include-with-prefix=, -include-with-prefix-after,
-include-with-prefix-after=, -include-with-prefix-before,
-include-with-prefix-before=, -no-integrated-cpp,
-no-line-commands, -no-standard-includes, -no-warnings, -output,
-output=, -pedantic, -pedantic-errors, -preprocess,
-print-missing-file-dependencies, -trace-includes, -traditional,
-traditional-cpp, -trigraphs, -undefine-macro, -undefine-macro=,
-user-dependencies, -verbose, -write-dependencies,
-write-user-dependencies, no-integrated-cpp, traditional): New.
fortran:
* gfortranspec.c (lang_specific_driver): Handle OPT__version and
OPT__help instead of OPT_fversion and OPT_fhelp.
* lang.opt (-all-warnings, -assert, -assert=, -comments,
-comments-in-macros, -define-macro, -define-macro=, -dependencies,
-dump, -dump=, -include-barrier, -include-directory,
-include-directory=, -include-directory-after,
-include-directory-after=, -include-prefix, -include-prefix=,
-no-line-commands, -no-standard-includes, -output, -output=,
-preprocess, -print-missing-file-dependencies, -trace-includes,
-undefine-macro, -undefine-macro=, -user-dependencies, -verbose,
-write-dependencies, -write-user-dependencies): New.
java:
* jvspec.c (lang_specific_driver): Handle OPT__help instead of
OPT_fhelp.
* lang.opt (-CLASSPATH, -all-warnings, -bootclasspath, -classpath,
-dependencies, -encoding, -extdirs, -include-directory,
-include-directory=, -output-class-directory,
-output-class-directory=, -resource, -resource=,
-user-dependencies): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164531 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 41 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/lang.opt | 20 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 150 | ||||
-rw-r--r-- | gcc/common.opt | 199 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/fortran/gfortranspec.c | 4 | ||||
-rw-r--r-- | gcc/fortran/lang.opt | 90 | ||||
-rw-r--r-- | gcc/gcc.c | 407 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/java/jvspec.c | 2 | ||||
-rw-r--r-- | gcc/java/lang.opt | 42 | ||||
-rw-r--r-- | gcc/opts-common.c | 259 | ||||
-rw-r--r-- | gcc/opts.c | 4 |
15 files changed, 821 insertions, 445 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cff05f21abf..5983420620c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,44 @@ +2010-09-22 Joseph Myers <joseph@codesourcery.com> + + * common.opt (-assemble, -compile, -coverage, -debug, -dump, + -dump=, -dumpbase, -dumpdir, -entry, -entry=, -extra-warnings, + -for-assembler, -for-assembler=, -for-linker, -for-linker=, + -force-link, -force-link=, -language, -language=, + -library-directory, -library-directory=, -no-canonical-prefixes, + -no-standard-libraries, -no-warnings, -optimize, -output, + -output=, -pass-exit-codes, -pedantic, -pedantic-errors, -pie, + -pipe, -prefix, -prefix=, -preprocess, -print-file-name, + -print-file-name=, -print-libgcc-file-name, + -print-multi-directory, -print-multi-lib, + -print-multi-os-directory, -print-prog-name, -print-prog-name=, + -print-search-dirs, -print-sysroot, -print-sysroot-headers-suffix, + -profile, -save-temps, -shared, -specs, -specs=, -static, + -symbolic, -time, -verbose, -param=, -sysroot, coverage, e, u, + symbolic): New. + (fhelp, fhelp=, ftarget-help, fversion): Make into aliases. + * gcc.c (A Short Introduction to Adding a Command-Line Option): + Remove comment. + (cc1_options): Correct specs for passing down --help, + --target-help and --help=*. Add spec for passing down --version. + (struct option_map, option_map, target_option_translations, + translate_options): Remove. + (driver_handle_option): Handle OPT__version, OPT__help, OPT__help_ + and OPT__target_help instead of OPT_fversion, OPT_fhelp, + OPT_fhelp_ and OPT_ftarget_help. + (process_command): Don't call translate_options. Call + decode_cmdline_options_to_array before checking for + -no-canonical-prefixes using decoded options. + * opts-common.c (tm.h): Update comment on #include. + (find_opt): Allow abbreviations of long options. + (struct option_map, option_map): New. + (decode_cmdline_option): Use them instead of hardcoding -Wno, -fno + and -mno handling. + (target_option_translations): New. + (decode_cmdline_options_to_array): Handle + TARGET_OPTION_TRANSLATE_TABLE in driver. + * opts.c (common_handle_option): Don't handle OPT_fhelp, + OPT_ftarget_help, OPT_fhelp_ or OPT_fversion. + 2010-09-22 Richard Guenther <rguenther@suse.de> * tree-inline.c (optimize_inline_calls): Schedule cleanups diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 15100f65100..42c3d3cd19b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2010-09-22 Joseph Myers <joseph@codesourcery.com> + + * gcc-interface/lang.opt (-all-warnings, -include-barrier, + -include-directory, -include-directory=, -no-standard-includes, + -no-standard-libraries): New. + 2010-09-20 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/decl.c (gnat_to_gnu_entity): Replace calls to diff --git a/gcc/ada/gcc-interface/lang.opt b/gcc/ada/gcc-interface/lang.opt index 586b0e6326e..3b9129b32cc 100644 --- a/gcc/ada/gcc-interface/lang.opt +++ b/gcc/ada/gcc-interface/lang.opt @@ -1,5 +1,5 @@ ; Options for the Ada front end. -; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc. +; Copyright (C) 2003, 2007, 2008, 2010 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -25,6 +25,24 @@ Language Ada +-all-warnings +Ada Alias(Wall) + +-include-barrier +Ada Alias(I, -) + +-include-directory +Ada Separate Alias(I) + +-include-directory= +Ada Joined Alias(I) + +-no-standard-includes +Ada Alias(nostdinc) + +-no-standard-libraries +Ada Alias(nostdlib) + I Ada Joined Separate ; Documented for C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c1085670b32..d708edbb39c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,21 @@ +2010-09-22 Joseph Myers <joseph@codesourcery.com> + + * c.opt (-all-warnings, -ansi, -assert, -assert=, -comments, + -comments-in-macros, -define-macro, -define-macro=, -dependencies, + -dump, -dump=, -imacros, -imacros=, -include, -include=, + -include-barrier, -include-directory, -include-directory=, + -include-directory-after, -include-directory-after=, + -include-prefix, -include-prefix=, -include-with-prefix, + -include-with-prefix=, -include-with-prefix-after, + -include-with-prefix-after=, -include-with-prefix-before, + -include-with-prefix-before=, -no-integrated-cpp, + -no-line-commands, -no-standard-includes, -no-warnings, -output, + -output=, -pedantic, -pedantic-errors, -preprocess, + -print-missing-file-dependencies, -trace-includes, -traditional, + -traditional-cpp, -trigraphs, -undefine-macro, -undefine-macro=, + -user-dependencies, -verbose, -write-dependencies, + -write-user-dependencies, no-integrated-cpp, traditional): New. + 2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/23710 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index a997f79cf8c..f91eeef5a31 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -34,9 +34,153 @@ C++ Language ObjC++ +-all-warnings +C ObjC C++ ObjC++ Warning Alias(Wall) + +-ansi +C ObjC C++ ObjC++ Alias(ansi) + +-assert +C ObjC C++ ObjC++ Separate Alias(A) MissingArgError(assertion missing after %qs) + +-assert= +C ObjC C++ ObjC++ Joined Alias(A) MissingArgError(assertion missing after %qs) + +-comments +C ObjC C++ ObjC++ Alias(C) + +-comments-in-macros +C ObjC C++ ObjC++ Alias(CC) + +-define-macro +C ObjC C++ ObjC++ Separate Alias(D) MissingArgError(macro name missing after %qs) + +-define-macro= +C ObjC C++ ObjC++ Joined Alias(D) MissingArgError(macro name missing after %qs) + +-dependencies +C ObjC C++ ObjC++ Alias(M) + +-dump +C ObjC C++ ObjC++ Separate Alias(d) + +-dump= +C ObjC C++ ObjC++ Joined Alias(d) + +-imacros +C ObjC C++ ObjC++ Separate Alias(imacros) MissingArgError(missing filename after %qs) + +-imacros= +C ObjC C++ ObjC++ Joined Alias(imacros) MissingArgError(missing filename after %qs) + +-include +C ObjC C++ ObjC++ Separate Alias(include) MissingArgError(missing filename after %qs) + +-include= +C ObjC C++ ObjC++ Joined Alias(include) MissingArgError(missing filename after %qs) + +-include-barrier +C ObjC C++ ObjC++ Alias(I, -) + +-include-directory +C ObjC C++ ObjC++ Separate Alias(I) MissingArgError(missing path after %qs) + +-include-directory= +C ObjC C++ ObjC++ Joined Alias(I) MissingArgError(missing path after %qs) + +-include-directory-after +C ObjC C++ ObjC++ Separate Alias(idirafter) MissingArgError(missing path after %qs) + +-include-directory-after= +C ObjC C++ ObjC++ Joined Alias(idirafter) MissingArgError(missing path after %qs) + +-include-prefix +C ObjC C++ ObjC++ Separate Alias(iprefix) + +-include-prefix= +C ObjC C++ ObjC++ JoinedOrMissing Alias(iprefix) + +-include-with-prefix +C ObjC C++ ObjC++ Separate Alias(iwithprefix) + +-include-with-prefix= +C ObjC C++ ObjC++ JoinedOrMissing Alias(iwithprefix) + +-include-with-prefix-after +C ObjC C++ ObjC++ Separate Alias(iwithprefix) + +-include-with-prefix-after= +C ObjC C++ ObjC++ JoinedOrMissing Alias(iwithprefix) + +-include-with-prefix-before +C ObjC C++ ObjC++ Separate Alias(iwithprefixbefore) + +-include-with-prefix-before= +C ObjC C++ ObjC++ JoinedOrMissing Alias(iwithprefixbefore) + +-no-integrated-cpp +Driver Alias(no-integrated-cpp) + +-no-line-commands +C ObjC C++ ObjC++ Alias(P) + +-no-standard-includes +C ObjC C++ ObjC++ Alias(nostdinc) + +-no-warnings +C ObjC C++ ObjC++ Alias(w) + +-output +C ObjC C++ ObjC++ Separate Alias(o) + +-output= +C ObjC C++ ObjC++ Joined Alias(o) + -output-pch= C ObjC C++ ObjC++ Joined Separate +-pedantic +C ObjC C++ ObjC++ Alias(pedantic) + +-pedantic-errors +C ObjC C++ ObjC++ Alias(pedantic-errors) + +-preprocess +C ObjC C++ ObjC++ Undocumented Alias(E) + +-print-missing-file-dependencies +C ObjC C++ ObjC++ Alias(MG) + +-trace-includes +C ObjC C++ ObjC++ Alias(H) + +-traditional +Driver Alias(traditional) + +-traditional-cpp +C ObjC C++ ObjC++ Alias(traditional-cpp) + +-trigraphs +C ObjC C++ ObjC++ Alias(trigraphs) + +-undefine-macro +C ObjC C++ ObjC++ Separate Alias(U) MissingArgError(macro name missing after %qs) + +-undefine-macro= +C ObjC C++ ObjC++ Joined Alias(U) MissingArgError(macro name missing after %qs) + +-user-dependencies +C ObjC C++ ObjC++ Alias(MM) + +-verbose +Common C ObjC C++ ObjC++ Alias(v) + +-write-dependencies +C ObjC C++ ObjC++ NoDriverArg Separate Alias(MD) MissingArgError(missing filename after %qs) + +-write-user-dependencies +C ObjC C++ ObjC++ NoDriverArg Separate Alias(MMD) MissingArgError(missing filename after %qs) + A C ObjC C++ ObjC++ Joined Separate MissingArgError(assertion missing after %qs) -A<question>=<answer> Assert the <answer> to <question>. Putting '-' before <question> disables the <answer> to <question> @@ -932,6 +1076,9 @@ C ObjC C++ ObjC++ Joined Separate lang-asm C Undocumented RejectDriver +no-integrated-cpp +Driver + nostdinc C ObjC C++ ObjC++ Do not search standard system include directories (those specified with -isystem will still be used) @@ -1038,6 +1185,9 @@ std=iso9899:199x C ObjC Alias(std=c99) Deprecated in favor of -std=iso9899:1999 +traditional +Driver + traditional-cpp C ObjC C++ ObjC++ Enable traditional preprocessing diff --git a/gcc/common.opt b/gcc/common.opt index 9d653f61ba3..119a64af0a8 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -29,37 +29,208 @@ int target_flags ### Driver +-assemble +Driver Alias(S) + +-compile +Driver Alias(c) + +-coverage +Driver Alias(coverage) + +-debug +Common Alias(g) + +-dump +Common Separate Alias(d) + +-dump= +Common Joined Alias(d) + +-dumpbase +Common Separate Alias(dumpbase) + +-dumpdir +Common Separate Alias(dumpdir) + +-entry +Driver Separate Alias(e) + +-entry= +Driver Joined Alias(e) + +-extra-warnings +Common Warning Alias(Wextra) + +-for-assembler +Driver Separate Alias(Xassembler) + +-for-assembler= +Driver JoinedOrMissing Alias(Xassembler) + +-for-linker +Driver Separate Alias(Xlinker) + +-for-linker= +Driver JoinedOrMissing Alias(Xlinker) + +-force-link +Driver Separate Alias(u) + +-force-link= +Driver Joined Alias(u) + -help -Common Driver +Common Driver Var(help_flag) Display this information -help= Common Driver Report Joined --help=<class> Display descriptions of a specific class of options. <class> is one or more of optimizers, target, warnings, undocumented, params +-language +Driver Separate Alias(x) + +-language= +Driver Joined Alias(x) + +-library-directory +Driver Separate Alias(L) + +-library-directory= +Driver Joined Alias(L) + +-no-canonical-prefixes +Driver Alias(no-canonical-prefixes) + +-no-standard-libraries +Driver Alias(nostdlib) + +-no-warnings +Common Alias(w) + +-optimize +Common Alias(O) + +-output +Common Driver Separate Alias(o) MissingArgError(missing filename after %qs) + +-output= +Common Driver Joined Alias(o) MissingArgError(missing filename after %qs) + +-pass-exit-codes +Driver Alias(pass-exit-codes) + +-pedantic +Common Alias(pedantic) + +-pedantic-errors +Common Alias(pedantic-errors) + +-pie +Common Alias(pie) + +-pipe +Driver Alias(pipe) + +-prefix +Driver Separate Alias(B) + +-prefix= +Driver JoinedOrMissing Alias(B) + +-preprocess +Driver Alias(E) + +-print-file-name +Driver Separate Alias(print-file-name=) + +-print-file-name= +Driver JoinedOrMissing Alias(print-file-name=) + +-print-libgcc-file-name +Driver Alias(print-libgcc-file-name) + +-print-multi-directory +Driver Alias(print-multi-directory) + +-print-multi-lib +Driver Alias(print-multi-lib) + +-print-multi-os-directory +Driver Alias(print-multi-os-directory) + +-print-prog-name +Driver Separate Alias(print-prog-name=) + +-print-prog-name= +Driver JoinedOrMissing Alias(print-prog-name=) + +-print-search-dirs +Driver Alias(print-search-dirs) + +-print-sysroot +Driver Alias(print-sysroot) + +-print-sysroot-headers-suffix +Driver Alias(print-sysroot-headers-suffix) + +-profile +Common Alias(p) + +-save-temps +Driver Alias(save-temps) + +-shared +Common Alias(shared) + +-specs +Driver Separate Alias(specs=) + +-specs= +Driver Joined Alias(specs=) + +-static +Driver Alias(static) + +-symbolic +Driver Alias(symbolic) + -target-help Common Driver Alias for --help=target -;; 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). +-time +Driver Alias(time) + +-verbose +Driver Alias(v) + +;; The driver used to convert options such as --help into forms such +;; as -fhelp; the following four entries are for compatibility with +;; any direct uses of those (undocumented) -f forms fhelp -Common Driver Var(help_flag) +Common Driver Alias(-help) fhelp= -Common Driver Joined +Common Driver Joined Alias(-help=) ftarget-help -Common Driver +Common Driver Alias(-target-help) fversion -Common Driver +Common Driver Alias(-version) -param Common Separate --param <param>=<value> Set parameter <param> to value. See below for a complete list of parameters +-param= +Common Joined Alias(-param) + +-sysroot +Driver Separate Alias(-sysroot=) + -sysroot= Driver JoinedOrMissing @@ -312,6 +483,9 @@ Common Separate RejectDriver auxbase-strip Common Separate RejectDriver +coverage +Driver + c Driver @@ -336,6 +510,9 @@ Driver dumpversion Driver +e +Driver Joined Separate + ; The version of the C++ ABI in use. The following values are allowed: ; ; 0: The version of the ABI believed most conformant with the C++ ABI @@ -1744,6 +1921,9 @@ Driver Var(report_times) time= Driver JoinedOrMissing +u +Driver Joined Separate + v Driver @@ -1787,6 +1967,9 @@ Driver static-libstdc++ Driver +symbolic +Driver + pie Common RejectNegative Negative(shared) Create a position independent executable diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ffe7df5be54..b9df02f668d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,17 @@ +2010-09-22 Joseph Myers <joseph@codesourcery.com> + + * gfortranspec.c (lang_specific_driver): Handle OPT__version and + OPT__help instead of OPT_fversion and OPT_fhelp. + * lang.opt (-all-warnings, -assert, -assert=, -comments, + -comments-in-macros, -define-macro, -define-macro=, -dependencies, + -dump, -dump=, -include-barrier, -include-directory, + -include-directory=, -include-directory-after, + -include-directory-after=, -include-prefix, -include-prefix=, + -no-line-commands, -no-standard-includes, -output, -output=, + -preprocess, -print-missing-file-dependencies, -trace-includes, + -undefine-macro, -undefine-macro=, -user-dependencies, -verbose, + -write-dependencies, -write-user-dependencies): New. + 2010-09-21 Jason Blevins <jrblevin@sdf.org> * intrinsics.texi (HYPOT, IMAGE_INDEX, BESSEL_JN, BESSEL_YN, diff --git a/gcc/fortran/gfortranspec.c b/gcc/fortran/gfortranspec.c index 4220280eb22..b79f6a25706 100644 --- a/gcc/fortran/gfortranspec.c +++ b/gcc/fortran/gfortranspec.c @@ -271,7 +271,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, verbose = 1; break; - case OPT_fversion: + case OPT__version: printf ("GNU Fortran %s%s\n", pkgversion_string, version_string); printf ("Copyright %s 2010 Free Software Foundation, Inc.\n\n", _("(C)")); @@ -282,7 +282,7 @@ For more information about these matters, see the file named COPYING\n\n")); exit (0); break; - case OPT_fhelp: + case OPT__help: /* Let gcc.c handle this, as it has a really cool facility for handling --help and --verbose --help. */ return; diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index a5a785b1b7c..d523bdfe66c 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -25,6 +25,96 @@ Language Fortran +-all-warnings +Fortran Alias(Wall) + +-assert +Fortran Separate Alias(A) + +-assert= +Fortran Joined Alias(A) + +-comments +Fortran Alias(C) + +-comments-in-macros +Fortran Alias(CC) + +-define-macro +Fortran Separate Alias(D) + +-define-macro= +Fortran Joined Alias(D) + +-dependencies +Fortran Alias(M) + +-dump +Fortran Separate Alias(d) + +-dump= +Fortran Joined Alias(d) + +-include-barrier +Fortran Alias(I, -) + +-include-directory +Fortran Separate Alias(I) + +-include-directory= +Fortran Joined Alias(I) + +-include-directory-after +Fortran Separate Alias(idirafter) + +-include-directory-after= +Fortran Joined Alias(idirafter) + +-include-prefix +Fortran Separate Alias(iprefix) + +-include-prefix= +Fortran JoinedOrMissing Alias(iprefix) + +-no-line-commands +Fortran Alias(P) + +-no-standard-includes +Fortran Alias(nostdinc) + +-output +Fortran Separate Alias(o) + +-output= +Fortran Joined Alias(o) + +-preprocess +Fortran Undocumented Alias(E) + +-print-missing-file-dependencies +Fortran Alias(MG) + +-trace-includes +Fortran Alias(H) + +-undefine-macro +Fortran Separate Alias(U) + +-undefine-macro= +Fortran Joined Alias(U) + +-user-dependencies +Fortran Alias(MM) + +-verbose +Fortran Alias(v) + +-write-dependencies +Fortran NoDriverArg Separate Alias(MD) + +-write-user-dependencies +Fortran NoDriverArg Separate Alias(MMD) + A Fortran Joined Separate ; Documented in C diff --git a/gcc/gcc.c b/gcc/gcc.c index b459a928e34..83bfbb9ee6b 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -30,44 +30,6 @@ CC recognizes how to compile each input file by suffixes in the file names. Once it knows which kind of compilation to perform, the procedure for compilation is specified by a string called a "spec". */ -/* A Short Introduction to Adding a Command-Line Option. - - Before adding a command-line option, consider if it is really - necessary. Each additional command-line option adds complexity and - is difficult to remove in subsequent versions. - - In the following, consider adding the command-line argument - `--bar'. - - 1. Each command-line option is specified in the specs file. The - notation is described below in the comment entitled "The Specs - Language". Read it. - - 2. In this file, add an entry to "option_map" equating the long - `--' argument version and any shorter, single letter version. Read - the comments in the declaration of "struct option_map" for an - explanation. Do not omit the first `-'. - - 3. Look in the "specs" file to determine which program or option - list should be given the argument, e.g., "cc1_options". Add the - appropriate syntax for the shorter option version to the - corresponding "const char *" entry in this file. Omit the first - `-' from the option. For example, use `-bar', rather than `--bar'. - - 4. If the argument takes an argument, e.g., `--baz argument1', - modify either DEFAULT_SWITCH_TAKES_ARG or - DEFAULT_WORD_SWITCH_TAKES_ARG in gcc.h. Omit the first `-' - from `--baz'. - - 5. Document the option in this file's display_help(). If the - option is passed to a subprogram, modify its corresponding - function, e.g., cppinit.c:print_help() or toplev.c:display_help(), - instead. - - 6. Compile and test. Make sure that your new specs file is being - read. For example, use a debugger to investigate the value of - "specs_file" in main(). */ - #include "config.h" #include "system.h" #include "coretypes.h" @@ -263,7 +225,6 @@ static void add_prefix (struct path_prefix *, const char *, const char *, int, int, int); static void add_sysrooted_prefix (struct path_prefix *, const char *, const char *, int, int, int); -static void translate_options (int *, const char *const **); static char *skip_whitespace (char *); static void delete_if_ordinary (const char *); static void delete_temp_files (void); @@ -802,9 +763,10 @@ static const char *cc1_options = %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \ %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ - %{Qn:-fno-ident} %{--help:--help}\ - %{--target-help:--target-help}\ - %{--help=*:--help=%(VALUE)}\ + %{Qn:-fno-ident} %{-help:--help}\ + %{-target-help:--target-help}\ + %{-version:--version}\ + %{-help=*:--help=%*}\ %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\ %{fsyntax-only:-o %j} %{-param*}\ %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants}\ @@ -1042,341 +1004,6 @@ static char **assembler_options; static int n_preprocessor_options; static char **preprocessor_options; -/* Define how to map long options into short ones. */ - -/* This structure describes one mapping. */ -struct option_map -{ - /* The long option's name. */ - const char *const name; - /* The equivalent short option. */ - const char *const equivalent; - /* Argument info. A string of flag chars; NULL equals no options. - a => argument required. - o => argument optional. - j => join argument to equivalent, making one word. - * => require other text after NAME as an argument. */ - const char *const arg_info; -}; - -/* This is the table of mappings. Mappings are tried sequentially - for each option encountered; the first one that matches, wins. */ - -static const struct option_map option_map[] = - { - {"--all-warnings", "-Wall", 0}, - {"--ansi", "-ansi", 0}, - {"--assemble", "-S", 0}, - {"--assert", "-A", "a"}, - {"--classpath", "-fclasspath=", "aj"}, - {"--bootclasspath", "-fbootclasspath=", "aj"}, - {"--CLASSPATH", "-fclasspath=", "aj"}, - {"--comments", "-C", 0}, - {"--comments-in-macros", "-CC", 0}, - {"--compile", "-c", 0}, - {"--debug", "-g", "oj"}, - {"--define-macro", "-D", "aj"}, - {"--dependencies", "-M", 0}, - {"--dump", "-d", "aj"}, - {"--dumpbase", "-dumpbase", "a"}, - {"--dumpdir", "-dumpdir", "a"}, - {"--encoding", "-fencoding=", "aj"}, - {"--entry", "-e", 0}, - {"--extra-warnings", "-W", 0}, - {"--extdirs", "-fextdirs=", "aj"}, - {"--for-assembler", "-Wa", "a"}, - {"--for-linker", "-Xlinker", "a"}, - {"--force-link", "-u", "a"}, - {"--coverage", "-coverage", 0}, - {"--imacros", "-imacros", "a"}, - {"--include", "-include", "a"}, - {"--include-barrier", "-I-", 0}, - {"--include-directory", "-I", "aj"}, - {"--include-directory-after", "-idirafter", "a"}, - {"--include-prefix", "-iprefix", "a"}, - {"--include-with-prefix", "-iwithprefix", "a"}, - {"--include-with-prefix-before", "-iwithprefixbefore", "a"}, - {"--include-with-prefix-after", "-iwithprefix", "a"}, - {"--language", "-x", "a"}, - {"--library-directory", "-L", "a"}, - {"--machine", "-m", "aj"}, - {"--machine-", "-m", "*j"}, - {"--no-canonical-prefixes", "-no-canonical-prefixes", 0}, - {"--no-integrated-cpp", "-no-integrated-cpp", 0}, - {"--no-line-commands", "-P", 0}, - {"--no-precompiled-includes", "-noprecomp", 0}, - {"--no-standard-includes", "-nostdinc", 0}, - {"--no-standard-libraries", "-nostdlib", 0}, - {"--no-warnings", "-w", 0}, - {"--optimize", "-O", "oj"}, - {"--output", "-o", "a"}, - {"--output-class-directory", "-foutput-class-dir=", "ja"}, - {"--param", "--param", "a"}, - {"--pass-exit-codes", "-pass-exit-codes", 0}, - {"--pedantic", "-pedantic", 0}, - {"--pedantic-errors", "-pedantic-errors", 0}, - {"--pie", "-pie", 0}, - {"--pipe", "-pipe", 0}, - {"--prefix", "-B", "a"}, - {"--preprocess", "-E", 0}, - {"--print-search-dirs", "-print-search-dirs", 0}, - {"--print-file-name", "-print-file-name=", "aj"}, - {"--print-libgcc-file-name", "-print-libgcc-file-name", 0}, - {"--print-missing-file-dependencies", "-MG", 0}, - {"--print-multi-lib", "-print-multi-lib", 0}, - {"--print-multi-directory", "-print-multi-directory", 0}, - {"--print-multi-os-directory", "-print-multi-os-directory", 0}, - {"--print-prog-name", "-print-prog-name=", "aj"}, - {"--print-sysroot", "-print-sysroot", 0}, - {"--print-sysroot-headers-suffix", "-print-sysroot-headers-suffix", 0}, - {"--profile", "-p", 0}, - {"--resource", "-fcompile-resource=", "aj"}, - {"--save-temps", "-save-temps", 0}, - {"--shared", "-shared", 0}, - {"--specs", "-specs=", "aj"}, - {"--static", "-static", 0}, - {"--std", "-std=", "aj"}, - {"--symbolic", "-symbolic", 0}, - {"--sysroot", "--sysroot=", "aj"}, - {"--time", "-time", 0}, - {"--trace-includes", "-H", 0}, - {"--traditional", "-traditional", 0}, - {"--traditional-cpp", "-traditional-cpp", 0}, - {"--trigraphs", "-trigraphs", 0}, - {"--undefine-macro", "-U", "aj"}, - {"--user-dependencies", "-MM", 0}, - {"--verbose", "-v", 0}, - {"--warn-", "-W", "*j"}, - {"--write-dependencies", "-MD", 0}, - {"--write-user-dependencies", "-MMD", 0}, - {"--", "-f", "*j"} - }; - - -#ifdef TARGET_OPTION_TRANSLATE_TABLE -static const struct { - const char *const option_found; - const char *const replacements; -} target_option_translations[] = -{ - TARGET_OPTION_TRANSLATE_TABLE, - { 0, 0 } -}; -#endif - -/* Translate the options described by *ARGCP and *ARGVP. - Make a new vector and store it back in *ARGVP, - and store its length in *ARGCP. */ - -static void -translate_options (int *argcp, const char *const **argvp) -{ - int i; - int argc = *argcp; - const char *const *argv = *argvp; - int newvsize = (argc + 2) * 2 * sizeof (const char *); - const char **newv = XNEWVAR (const char *, newvsize); - int newindex = 0; - - i = 0; - newv[newindex++] = argv[i++]; - - while (i < argc) - { -#ifdef TARGET_OPTION_TRANSLATE_TABLE - int tott_idx; - - for (tott_idx = 0; - target_option_translations[tott_idx].option_found; - tott_idx++) - { - if (strcmp (target_option_translations[tott_idx].option_found, - argv[i]) == 0) - { - int spaces = 1; - const char *sp; - char *np; - - for (sp = target_option_translations[tott_idx].replacements; - *sp; sp++) - { - if (*sp == ' ') - spaces ++; - } - - newvsize += spaces * sizeof (const char *); - newv = XRESIZEVAR (const char *, newv, newvsize); - - sp = target_option_translations[tott_idx].replacements; - np = xstrdup (sp); - - while (1) - { - while (*np == ' ') - np++; - if (*np == 0) - break; - newv[newindex++] = np; - while (*np != ' ' && *np) - np++; - if (*np == 0) - break; - *np++ = 0; - } - - i ++; - break; - } - } - if (target_option_translations[tott_idx].option_found) - continue; -#endif - - /* Translate -- options. */ - if (argv[i][0] == '-' && argv[i][1] == '-') - { - size_t j; - /* Find a mapping that applies to this option. */ - for (j = 0; j < ARRAY_SIZE (option_map); j++) - { - size_t optlen = strlen (option_map[j].name); - size_t arglen = strlen (argv[i]); - size_t complen = arglen > optlen ? optlen : arglen; - const char *arginfo = option_map[j].arg_info; - - if (arginfo == 0) - arginfo = ""; - - if (!strncmp (argv[i], option_map[j].name, complen)) - { - const char *arg = 0; - - if (arglen < optlen) - { - size_t k; - for (k = j + 1; k < ARRAY_SIZE (option_map); k++) - if (strlen (option_map[k].name) >= arglen - && !strncmp (argv[i], option_map[k].name, arglen)) - { - error ("ambiguous abbreviation %s", argv[i]); - break; - } - - if (k != ARRAY_SIZE (option_map)) - break; - } - - if (arglen > optlen) - { - /* If the option has an argument, accept that. */ - if (argv[i][optlen] == '=') - arg = argv[i] + optlen + 1; - - /* If this mapping requires extra text at end of name, - accept that as "argument". */ - else if (strchr (arginfo, '*') != 0) - arg = argv[i] + optlen; - - /* Otherwise, extra text at end means mismatch. - Try other mappings. */ - else - continue; - } - - else if (strchr (arginfo, '*') != 0) - { - error ("incomplete %qs option", option_map[j].name); - break; - } - - /* Handle arguments. */ - if (strchr (arginfo, 'a') != 0) - { - if (arg == 0) - { - if (i + 1 == argc) - { - error ("missing argument to %qs option", - option_map[j].name); - break; - } - - arg = argv[++i]; - } - } - else if (strchr (arginfo, '*') != 0) - ; - else if (strchr (arginfo, 'o') == 0) - { - if (arg != 0) - error ("extraneous argument to %qs option", - option_map[j].name); - arg = 0; - } - - /* Store the translation as one argv elt or as two. */ - if (arg != 0 && strchr (arginfo, 'j') != 0) - newv[newindex++] = concat (option_map[j].equivalent, arg, - NULL); - else if (arg != 0) - { - newv[newindex++] = option_map[j].equivalent; - newv[newindex++] = arg; - } - else - newv[newindex++] = option_map[j].equivalent; - - break; - } - } - i++; - } - - /* Handle old-fashioned options--just copy them through, - with their arguments. */ - else if (argv[i][0] == '-') - { - const char *p = argv[i] + 1; - int c = *p; - int nskip = 1; - - if (SWITCH_TAKES_ARG (c) > (p[1] != 0)) - nskip += SWITCH_TAKES_ARG (c) - (p[1] != 0); - else if (WORD_SWITCH_TAKES_ARG (p)) - nskip += WORD_SWITCH_TAKES_ARG (p); - else if ((c == 'B' || c == 'b' || c == 'x') - && p[1] == 0) - nskip += 1; - else if (! strcmp (p, "Xlinker")) - nskip += 1; - else if (! strcmp (p, "Xpreprocessor")) - nskip += 1; - else if (! strcmp (p, "Xassembler")) - nskip += 1; - - /* Watch out for an option at the end of the command line that - is missing arguments, and avoid skipping past the end of the - command line. */ - if (nskip + i > argc) - nskip = argc - i; - - while (nskip > 0) - { - newv[newindex++] = argv[i++]; - nskip--; - } - } - else - /* Ordinary operands. */ - newv[newindex++] = argv[i++]; - } - - newv[newindex] = 0; - - *argvp = newv; - *argcp = newindex; -} - static char * skip_whitespace (char *p) { @@ -3546,8 +3173,7 @@ driver_handle_option (const struct cl_decoded_option *decoded, printf ("%s\n", spec_machine); exit (0); - case OPT_fversion: - /* translate_options () has turned --version into -fversion. */ + case OPT__version: print_version = 1; /* CPP driver cannot obtain switch from cc1_options. */ @@ -3557,8 +3183,7 @@ driver_handle_option (const struct cl_decoded_option *decoded, add_linker_option ("--version", strlen ("--version")); break; - case OPT_fhelp: - /* translate_options () has turned --help into -fhelp. */ + case OPT__help: print_help_list = 1; /* CPP driver cannot obtain switch from cc1_options. */ @@ -3568,13 +3193,11 @@ driver_handle_option (const struct cl_decoded_option *decoded, add_linker_option ("--help", 6); break; - case OPT_fhelp_: - /* translate_options () has turned --help into -fhelp. */ + case OPT__help_: print_subprocess_help = 2; break; - case OPT_ftarget_help: - /* translate_options() has turned --target-help into -ftarget-help. */ + case OPT__target_help: print_subprocess_help = 1; /* CPP driver cannot obtain switch from cc1_options. */ @@ -3885,7 +3508,6 @@ driver_handle_option (const struct cl_decoded_option *decoded, static void process_command (int argc, const char **argv) { - int i; const char *temp; char *temp1; const char *tooldir_prefix; @@ -3914,18 +3536,16 @@ process_command (int argc, const char **argv) } } - /* Convert new-style -- options to old-style. */ - translate_options (&argc, - CONST_CAST2 (const char *const **, const char ***, - &argv)); + decode_cmdline_options_to_array (argc, argv, CL_DRIVER, + &decoded_options, &decoded_options_count); /* Handle any -no-canonical-prefixes flag early, to assign the function that builds relative prefixes. This function creates default search paths that are needed later in normal option handling. */ - for (i = 1; i < argc; i++) + for (j = 1; j < decoded_options_count; j++) { - if (! strcmp (argv[i], "-no-canonical-prefixes")) + if (decoded_options[j].opt_index == OPT_no_canonical_prefixes) { get_relative_prefix = make_relative_prefix_ignore_links; break; @@ -3974,9 +3594,6 @@ process_command (int argc, const char **argv) is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX or an automatically created GCC_EXEC_PREFIX from argv[0]. */ - decode_cmdline_options_to_array (argc, argv, CL_DRIVER, - &decoded_options, &decoded_options_count); - /* Do language-specific adjustment/addition of flags. */ lang_specific_driver (&decoded_options, &decoded_options_count, &added_libraries); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 4685dd4b4f2..f1a1ee1c0fb 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,13 @@ +2010-09-22 Joseph Myers <joseph@codesourcery.com> + + * jvspec.c (lang_specific_driver): Handle OPT__help instead of + OPT_fhelp. + * lang.opt (-CLASSPATH, -all-warnings, -bootclasspath, -classpath, + -dependencies, -encoding, -extdirs, -include-directory, + -include-directory=, -output-class-directory, + -output-class-directory=, -resource, -resource=, + -user-dependencies): New. + 2010-09-16 Richard Guenther <rguenther@suse.de> * jcf-parse.c (current_file_list): Remove. diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index c7f5273dfc8..7fe44f3b23d 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -238,7 +238,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, added--; break; - case OPT_fhelp: + case OPT__help: want_spec_file = 0; break; diff --git a/gcc/java/lang.opt b/gcc/java/lang.opt index 7350ccbe08c..8f529787f4d 100644 --- a/gcc/java/lang.opt +++ b/gcc/java/lang.opt @@ -24,6 +24,48 @@ Language Java +-CLASSPATH +Java Separate Alias(fclasspath=) + +-all-warnings +Java Alias(Wall) + +-bootclasspath +Java Separate Alias(fbootclasspath=) + +-classpath +Java Separate Alias(fclasspath=) + +-dependencies +Java Alias(M) + +-encoding +Java Separate Alias(fencoding=) + +-extdirs +Java Separate Alias(fextdirs=) + +-include-directory +Java Separate Alias(I) + +-include-directory= +Java Joined Alias(I) + +-output-class-directory +Java Separate Alias(foutput-class-dir=) + +-output-class-directory= +Java Joined Alias(foutput-class-dir=) + +-resource +Java Separate Alias(fcompile-resource=) + +-resource= +Java Joined Alias(fcompile-resource=) + +-user-dependencies +Java Alias(MM) + C Driver ; Java driver option in fact distinct from C-family option with the same name. diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 8299edd4ab9..678b60e891b 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -24,7 +24,8 @@ along with GCC; see the file COPYING3. If not see #include "opts.h" #include "options.h" #include "diagnostic.h" -#include "tm.h" /* For SWITCH_TAKES_ARG and WORD_SWITCH_TAKES_ARG. */ +#include "tm.h" /* For SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG and + TARGET_OPTION_TRANSLATE_TABLE. */ /* Perform a binary search to find which option the command-line INPUT matches. Returns its index in the option array, and @@ -53,7 +54,7 @@ along with GCC; see the file COPYING3. If not see size_t find_opt (const char *input, int lang_mask) { - size_t mn, mx, md, opt_len; + size_t mn, mn_orig, mx, md, opt_len; size_t match_wrong_lang; int comp; @@ -74,6 +75,8 @@ find_opt (const char *input, int lang_mask) mn = md; } + mn_orig = mn; + /* This is the switch that is the best match but for a different front end, or OPT_SPECIAL_unknown if there is no match at all. */ match_wrong_lang = OPT_SPECIAL_unknown; @@ -106,6 +109,40 @@ find_opt (const char *input, int lang_mask) } while (mn != cl_options_count); + if (match_wrong_lang == OPT_SPECIAL_unknown && input[0] == '-') + { + /* Long options, starting "--", may be abbreviated if the + abbreviation is unambiguous. This only applies to options + not taking a joined argument, and abbreviations of "--option" + are permitted even if there is a variant "--option=". */ + size_t mnc = mn_orig + 1; + size_t cmp_len = strlen (input); + while (mnc < cl_options_count + && strncmp (input, cl_options[mnc].opt_text + 1, cmp_len) == 0) + { + /* Option matching this abbreviation. OK if it is the first + match and that does not take a joined argument, or the + second match, taking a joined argument and with only '=' + added to the first match; otherwise considered + ambiguous. */ + if (mnc == mn_orig + 1 + && !(cl_options[mnc].flags & CL_JOINED)) + match_wrong_lang = mnc; + else if (mnc == mn_orig + 2 + && match_wrong_lang == mn_orig + 1 + && (cl_options[mnc].flags & CL_JOINED) + && (cl_options[mnc].opt_len + == cl_options[mn_orig + 1].opt_len + 1) + && strncmp (cl_options[mnc].opt_text + 1, + cl_options[mn_orig + 1].opt_text + 1, + cl_options[mn_orig + 1].opt_len) == 0) + ; /* OK, as long as there are no more matches. */ + else + return OPT_SPECIAL_unknown; + mnc++; + } + } + /* Return the best wrong match, or OPT_SPECIAL_unknown if none. */ return match_wrong_lang; } @@ -197,6 +234,46 @@ generate_canonical_option (size_t opt_index, const char *arg, int value, } } +/* Structure describing mappings from options on the command line to + options to look up with find_opt. */ +struct option_map +{ + /* Prefix of the option on the command line. */ + const char *opt0; + /* If two argv elements are considered to be merged into one option, + prefix for the second element, otherwise NULL. */ + const char *opt1; + /* The new prefix to map to. */ + const char *new_prefix; + /* Whether at least one character is needed following opt1 or opt0 + for this mapping to be used. (--optimize= is valid for -O, but + --warn- is not valid for -W.) */ + bool another_char_needed; + /* Whether the original option is a negated form of the option + resulting from this map. */ + bool negated; +}; +static const struct option_map option_map[] = + { + { "-Wno-", NULL, "-W", false, true }, + { "-fno-", NULL, "-f", false, true }, + { "-mno-", NULL, "-m", false, true }, + { "--debug=", NULL, "-g", false, false }, + { "--machine-", NULL, "-m", true, false }, + { "--machine-no-", NULL, "-m", false, true }, + { "--machine=", NULL, "-m", false, false }, + { "--machine=no-", NULL, "-m", false, true }, + { "--machine", "", "-m", false, false }, + { "--machine", "no-", "-m", false, true }, + { "--optimize=", NULL, "-O", false, false }, + { "--std=", NULL, "-std=", false, false }, + { "--std", "", "-std=", false, false }, + { "--warn-", NULL, "-W", true, false }, + { "--warn-no-", NULL, "-W", false, true }, + { "--", NULL, "-f", true, false }, + { "--no-", NULL, "-f", false, true } + }; + /* Decode the switch beginning at ARGV for the language indicated by LANG_MASK (including CL_COMMON and CL_TARGET if applicable), into the structure *DECODED. Returns the number of switches @@ -207,10 +284,10 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, struct cl_decoded_option *decoded) { size_t opt_index; - const char *opt, *arg = 0; - char *dup = 0; + const char *arg = 0; int value = 1; - unsigned int result = 1, i; + unsigned int result = 1, i, extra_args; + int adjust_len = 0; size_t total_len; char *p; const struct cl_option *option; @@ -220,28 +297,50 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, bool joined_arg_flag; bool have_separate_arg = false; - opt = argv[0]; + extra_args = 0; - opt_index = find_opt (opt + 1, lang_mask); - if (opt_index == OPT_SPECIAL_unknown - && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm') - && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-') + opt_index = find_opt (argv[0] + 1, lang_mask); + i = 0; + while (opt_index == OPT_SPECIAL_unknown + && i < ARRAY_SIZE (option_map)) { - /* Drop the "no-" from negative switches. */ - size_t len = strlen (opt) - 3; - - dup = XNEWVEC (char, 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); + const char *opt0 = option_map[i].opt0; + const char *opt1 = option_map[i].opt1; + const char *new_prefix = option_map[i].new_prefix; + bool another_char_needed = option_map[i].another_char_needed; + size_t opt0_len = strlen (opt0); + size_t opt1_len = (opt1 == NULL ? 0 : strlen (opt1)); + size_t optn_len = (opt1 == NULL ? opt0_len : opt1_len); + size_t new_prefix_len = strlen (new_prefix); + + extra_args = (opt1 == NULL ? 0 : 1); + value = !option_map[i].negated; + + if (strncmp (argv[0], opt0, opt0_len) == 0 + && (opt1 == NULL + || (argv[1] != NULL && strncmp (argv[1], opt1, opt1_len) == 0)) + && (!another_char_needed + || argv[extra_args][optn_len] != 0)) + { + size_t arglen = strlen (argv[extra_args]); + char *dup; + + adjust_len = (int) optn_len - (int) new_prefix_len; + dup = XNEWVEC (char, arglen + 1 - adjust_len); + memcpy (dup, new_prefix, new_prefix_len); + memcpy (dup + new_prefix_len, argv[extra_args] + optn_len, + arglen - optn_len + 1); + opt_index = find_opt (dup + 1, lang_mask); + free (dup); + } + i++; } if (opt_index == OPT_SPECIAL_unknown) { arg = argv[0]; + extra_args = 0; + value = 1; goto done; } @@ -257,6 +356,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, goto done; } + result = extra_args + 1; warn_message = option->warn_message; /* Check to see if the option is disabled for this configuration. */ @@ -276,18 +376,16 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, /* 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-"); + arg = argv[extra_args] + cl_options[opt_index].opt_len + 1 + adjust_len; if (*arg == '\0' && !(option->flags & CL_MISSING_OK)) { if (separate_arg_flag) { - arg = argv[1]; - result = 2; + arg = argv[extra_args + 1]; + result = extra_args + 2; if (arg == NULL) - result = 1; + result = extra_args + 1; else have_separate_arg = true; } @@ -298,10 +396,10 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, } else if (separate_arg_flag) { - arg = argv[1]; - result = 2; + arg = argv[extra_args + 1]; + result = extra_args + 2; if (arg == NULL) - result = 1; + result = extra_args + 1; else have_separate_arg = true; } @@ -329,7 +427,8 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, const struct cl_option *new_option = &cl_options[new_opt_index]; /* The new option must not be an alias itself. */ - gcc_assert (new_option->alias_target == N_OPTS); + gcc_assert (new_option->alias_target == N_OPTS + || (new_option->flags & CL_SEPARATE_ALIAS)); if (option->neg_alias_arg) { @@ -363,7 +462,11 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, if (!(errors & CL_ERR_MISSING_ARG)) { if (separate_arg_flag || joined_arg_flag) - gcc_assert (arg != NULL); + { + if ((option->flags & CL_MISSING_OK) && arg == NULL) + arg = ""; + gcc_assert (arg != NULL); + } else gcc_assert (arg == NULL); } @@ -392,8 +495,6 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, } done: - if (dup) - free (dup); decoded->opt_index = opt_index; decoded->arg = arg; decoded->value = value; @@ -455,6 +556,17 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, return result; } +#ifdef TARGET_OPTION_TRANSLATE_TABLE +static const struct { + const char *const option_found; + const char *const replacements; +} target_option_translations[] = +{ + TARGET_OPTION_TRANSLATE_TABLE, + { 0, 0 } +}; +#endif + /* Decode command-line options (ARGC and ARGV being the arguments of main) into an array, setting *DECODED_OPTIONS to a pointer to that array and *DECODED_OPTIONS_COUNT to the number of entries in the @@ -470,9 +582,10 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count) { - unsigned int n, i; + unsigned int n, i, target_translate_from; struct cl_decoded_option *opt_array; unsigned int num_decoded_options; + bool argv_copied = false; opt_array = XNEWVEC (struct cl_decoded_option, argc); @@ -489,6 +602,7 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, opt_array[0].errors = 0; num_decoded_options = 1; + target_translate_from = 1; for (i = 1; i < argc; i += n) { const char *opt = argv[i]; @@ -502,11 +616,88 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, continue; } + if (i >= target_translate_from && (lang_mask & CL_DRIVER)) + { +#ifdef TARGET_OPTION_TRANSLATE_TABLE + int tott_idx; + + for (tott_idx = 0; + target_option_translations[tott_idx].option_found; + tott_idx++) + { + if (strcmp (target_option_translations[tott_idx].option_found, + argv[i]) == 0) + { + unsigned int spaces = 0; + unsigned int m = 0; + const char *sp; + char *np; + + for (sp = target_option_translations[tott_idx].replacements; + *sp; sp++) + { + if (*sp == ' ') + { + spaces++; + while (*sp == ' ') + sp++; + sp--; + } + } + + if (spaces) + { + int new_argc = argc + spaces; + if (argv_copied) + argv = XRESIZEVEC (const char *, argv, new_argc + 1); + else + { + const char **new_argv = XNEWVEC (const char *, + new_argc + 1); + memcpy (new_argv, argv, + (argc + 1) * sizeof (const char *)); + argv = new_argv; + argv_copied = true; + } + memmove (&argv[i] + spaces, &argv[i], + (argc + 1 - i) * sizeof (const char *)); + argc = new_argc; + opt_array = XRESIZEVEC (struct cl_decoded_option, + opt_array, argc); + } + + sp = target_option_translations[tott_idx].replacements; + np = xstrdup (sp); + + while (1) + { + while (*np == ' ') + np++; + if (*np == 0) + break; + argv[i + m++] = np; + while (*np != ' ' && *np) + np++; + if (*np == 0) + break; + *np++ = 0; + } + + target_translate_from = i + m; + gcc_assert (m == spaces + 1); + break; + } + } +#endif + } + n = decode_cmdline_option (argv + i, lang_mask, &opt_array[num_decoded_options]); num_decoded_options++; } + if (argv_copied) + free (argv); opt_array = XRESIZEVEC (struct cl_decoded_option, opt_array, num_decoded_options); *decoded_options = opt_array; diff --git a/gcc/opts.c b/gcc/opts.c index 49c91a4a094..643f88999d5 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1429,7 +1429,6 @@ common_handle_option (const struct cl_decoded_option *decoded, verbose = true; break; - case OPT_fhelp: case OPT__help: { unsigned int all_langs_mask = (1U << cl_lang_count) - 1; @@ -1451,7 +1450,6 @@ common_handle_option (const struct cl_decoded_option *decoded, break; } - case OPT_ftarget_help: case OPT__target_help: print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0); exit_after_options = true; @@ -1461,7 +1459,6 @@ common_handle_option (const struct cl_decoded_option *decoded, targetm.help (); break; - case OPT_fhelp_: case OPT__help_: { const char * a = arg; @@ -1580,7 +1577,6 @@ common_handle_option (const struct cl_decoded_option *decoded, break; } - case OPT_fversion: case OPT__version: exit_after_options = true; break; |