aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2002-08-08 06:30:13 +0000
committerNeil Booth <neil@gcc.gnu.org>2002-08-08 06:30:13 +0000
commit18bdccaab2e828b7aa68ee17e9e5ffee186ab61e (patch)
tree8b629d54956eb4101b6d0da970b9e94f92d15496 /gcc
parent50ad96428042fa526d001309059a6187dd9e0d3c (diff)
downloadgcc-18bdccaab2e828b7aa68ee17e9e5ffee186ab61e.zip
gcc-18bdccaab2e828b7aa68ee17e9e5ffee186ab61e.tar.gz
gcc-18bdccaab2e828b7aa68ee17e9e5ffee186ab61e.tar.bz2
c-opts.c (cpp_opts): New.
* c-opts.c (cpp_opts): New. (COMMAND_LINE_OPTIONS): Add switches from cppinit.c. (c_common_decode_options): Handle cpplib switches. (c_common_init_options): Set cpp_opts. * cppinit.c (COMMAND_LINE_OPTIONS): Move some switches to c-opts.c. (cpp_handle_option): Similarly. From-SVN: r56119
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c-opts.c117
-rw-r--r--gcc/cppinit.c132
3 files changed, 122 insertions, 136 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 18ffc97..473d88c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2002-08-08 Neil Booth <neil@daikokuya.co.uk>
+
+ * c-opts.c (cpp_opts): New.
+ (COMMAND_LINE_OPTIONS): Add switches from cppinit.c.
+ (c_common_decode_options): Handle cpplib switches.
+ (c_common_init_options): Set cpp_opts.
+ * cppinit.c (COMMAND_LINE_OPTIONS): Move some switches to c-opts.c.
+ (cpp_handle_option): Similarly.
+
2002-08-08 David Edelsohn <edelsohn@gnu.org>
* config/rs6000/aix.h (TARGET_ALTIVEC): Define to 0.
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index 6ad9650..c729211 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -30,6 +30,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tree-inline.h"
#include "diagnostic.h"
+static cpp_options *cpp_opts;
+
static void missing_arg PARAMS ((size_t));
static size_t parse_option PARAMS ((const char *, int));
static void set_Wimplicit PARAMS ((int));
@@ -52,24 +54,42 @@ static void write_langs PARAMS ((char *, int));
/* This is the list of all command line options, with the leading "-"
removed. It must be sorted in ASCII collating order. All options
beginning with "f" or "W" are implicitly assumed to take a "no-"
- form; this form should not be listed. If you don't want a "no-"
- form, your handler should check and reject it.
+ form; this form should not be listed. The variable "on" is true if
+ the positive form is given, otherwise it is false. If you don't
+ want to allow a "no-" form, your handler should reject "on" being
+ false by returning zero. See, for example, the handling of
+ -ftabstop=.
If the user gives an option to a front end that doesn't support it,
an error is output, mentioning which front ends the option is valid
for. If you don't want this, you must accept it for all front
- ends, and test for the front end in the option handler. */
+ ends, and test for the front end in the option handler. See, for
+ example, the handling of -Wno-strict-prototypes for C++.
+
+ If you request an argument with CL_JOINED, CL_SEPARATE or their
+ combination CL_ARG, it is stored in the variable "arg", which is
+ guaranteed non-NULL. It points to the argument either within the
+ argv[] vector or within one of its strings, and so the text is not
+ temporary and copies need not be made.
+
+ If you use the CL_SEPARATE flag (which is also in CL_ARG) be sure
+ to add an error message in missing_arg(). */
+
#define COMMAND_LINE_OPTIONS \
OPT("E", CL_ALL, OPT_E) \
OPT("Wall", CL_ALL, OPT_Wall) \
OPT("Wbad-function-cast", CL_C, OPT_Wbad_function_cast) \
OPT("Wcast-qual", CL_ALL, OPT_Wcast_qual) \
OPT("Wchar-subscripts", CL_ALL, OPT_Wchar_subscripts) \
+ OPT("Wcomment", CL_ALL, OPT_Wcomment) \
+ OPT("Wcomments", CL_ALL, OPT_Wcomments) \
OPT("Wconversion", CL_ALL, OPT_Wconversion) \
OPT("Wctor-dtor-privacy", CL_CXX, OPT_Wctor_dtor_privacy) \
OPT("Wdeprecated", CL_CXX, OPT_Wdeprecated) \
OPT("Wdiv-by-zero", CL_C, OPT_Wdiv_by_zero) \
OPT("Weffc++", CL_CXX, OPT_Weffcxx) \
+ OPT("Wendif-labels", CL_ALL, OPT_Wendif_labels) \
+ OPT("Werror", CL_ALL, OPT_Werror) \
OPT("Werror-implicit-function-declaration", \
CL_C, OPT_Werror_implicit_function_decl) \
OPT("Wfloat-equal", CL_ALL, OPT_Wfloat_equal) \
@@ -83,6 +103,7 @@ static void write_langs PARAMS ((char *, int));
OPT("Wimplicit", CL_CXX, OPT_Wimplicit) \
OPT("Wimplicit-function-declaration", CL_C, OPT_Wimplicit_function_decl) \
OPT("Wimplicit-int", CL_C, OPT_Wimplicit_int) \
+ OPT("Wimport", CL_ALL, OPT_Wimport) \
OPT("Wlong-long", CL_ALL, OPT_Wlong_long) \
OPT("Wmain", CL_C, OPT_Wmain) \
OPT("Wmissing-braces", CL_ALL, OPT_Wmissing_braces) \
@@ -109,8 +130,12 @@ static void write_langs PARAMS ((char *, int));
OPT("Wsign-promo", CL_CXX, OPT_Wsign_promo) \
OPT("Wstrict-prototypes", CL_ALL, OPT_Wstrict_prototypes) \
OPT("Wsynth", CL_CXX, OPT_Wsynth) \
+ OPT("Wsystem-headers", CL_ALL, OPT_Wsystem_headers) \
OPT("Wtraditional", CL_C, OPT_Wtraditional) \
+ OPT("Wtrigraphs", CL_ALL, OPT_Wtrigraphs) \
+ OPT("Wundef", CL_ALL, OPT_Wundef) \
OPT("Wunknown-pragmas", CL_ALL, OPT_Wunknown_pragmas) \
+ OPT("Wunused-macros", CL_ALL, OPT_Wunused_macros) \
OPT("Wwrite-strings", CL_ALL, OPT_Wwrite_strings) \
OPT("ansi", CL_ALL, OPT_ansi) \
OPT("faccess-control", CL_CXX, OPT_faccess_control) \
@@ -151,18 +176,22 @@ static void write_langs PARAMS ((char *, int));
OPT("fnext-runtime", CL_OBJC, OPT_fnext_runtime) \
OPT("fnonansi-builtins", CL_CXX, OPT_fnonansi_builtins) \
OPT("fnonnull-objects", CL_CXX, OPT_fnonnull_objects) \
+ OPT("foperator-names", CL_CXX, OPT_foperator_names) \
OPT("foptional-diags", CL_CXX, OPT_foptional_diags) \
OPT("fpermissive", CL_CXX, OPT_fpermissive) \
+ OPT("fpreprocessed", CL_ALL, OPT_fpreprocessed) \
OPT("frepo", CL_CXX, OPT_frepo) \
OPT("frtti", CL_CXX, OPT_frtti) \
OPT("fshort-double", CL_ALL, OPT_fshort_double) \
OPT("fshort-enums", CL_ALL, OPT_fshort_enums) \
OPT("fshort-wchar", CL_ALL, OPT_fshort_wchar) \
+ OPT("fshow-column", CL_ALL, OPT_fshow_column) \
OPT("fsigned-bitfields", CL_ALL, OPT_fsigned_bitfields) \
OPT("fsigned-char", CL_ALL, OPT_fsigned_char) \
OPT("fsquangle", CL_CXX, OPT_fsquangle) \
OPT("fstats", CL_CXX, OPT_fstats) \
OPT("fstrict-prototype", CL_CXX, OPT_fstrict_prototype) \
+ OPT("ftabstop=", CL_ALL | CL_JOINED, OPT_ftabstop) \
OPT("ftemplate-depth-", CL_CXX | CL_JOINED, OPT_ftemplate_depth) \
OPT("fthis-is-variable", CL_CXX, OPT_fthis_is_variable) \
OPT("funsigned-bitfields", CL_ALL, OPT_funsigned_bitfields) \
@@ -173,6 +202,8 @@ static void write_langs PARAMS ((char *, int));
OPT("fweak", CL_CXX, OPT_fweak) \
OPT("fxref", CL_CXX, OPT_fxref) \
OPT("gen-decls", CL_OBJC, OPT_gen_decls) \
+ 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("std=c++98", CL_CXX, OPT_std_cplusplus98) \
@@ -337,8 +368,10 @@ c_common_init_options (lang)
c_language = lang;
parse_in = cpp_create_reader (lang == clk_c || lang == clk_objective_c
? CLK_GNUC89 : CLK_GNUCXX);
+ cpp_opts = cpp_get_options (parse_in);
+
if (lang == clk_objective_c)
- cpp_get_options (parse_in)->objc = 1;
+ cpp_opts->objc = 1;
flag_const_strings = (lang == clk_cplusplus);
warn_pointer_arith = (lang == clk_cplusplus);
@@ -472,6 +505,10 @@ c_common_decode_option (argc, argv)
warn_reorder = on;
warn_nontemplate_friend = on;
}
+
+ cpp_opts->warn_trigraphs = on;
+ cpp_opts->warn_comments = on;
+ cpp_opts->warn_num_sign_change = on;
break;
case OPT_Wbad_function_cast:
@@ -486,6 +523,11 @@ c_common_decode_option (argc, argv)
warn_char_subscripts = on;
break;
+ case OPT_Wcomment:
+ case OPT_Wcomments:
+ cpp_opts->warn_comments = on;
+ break;
+
case OPT_Wconversion:
warn_conversion = on;
break;
@@ -506,6 +548,14 @@ c_common_decode_option (argc, argv)
warn_ecpp = on;
break;
+ case OPT_Wendif_labels:
+ cpp_opts->warn_endif_labels = on;
+ break;
+
+ case OPT_Werror:
+ cpp_opts->warnings_are_errors = on;
+ break;
+
case OPT_Werror_implicit_function_decl:
if (!on)
{
@@ -559,6 +609,10 @@ c_common_decode_option (argc, argv)
warn_implicit_int = on;
break;
+ case OPT_Wimport:
+ cpp_opts->warn_import = on;
+ break;
+
case OPT_Wlong_long:
warn_long_long = on;
break;
@@ -669,8 +723,21 @@ c_common_decode_option (argc, argv)
warn_synth = on;
break;
+ case OPT_Wsystem_headers:
+ cpp_opts->warn_system_headers = on;
+ break;
+
case OPT_Wtraditional:
warn_traditional = on;
+ cpp_opts->warn_traditional = on;
+ break;
+
+ case OPT_Wtrigraphs:
+ cpp_opts->warn_trigraphs = on;
+ break;
+
+ case OPT_Wundef:
+ cpp_opts->warn_undef = on;
break;
case OPT_Wunknown_pragmas:
@@ -679,6 +746,10 @@ c_common_decode_option (argc, argv)
warn_unknown_pragmas = on * 2;
break;
+ case OPT_Wunused_macros:
+ cpp_opts->warn_unused_macros = on;
+ break;
+
case OPT_Wwrite_strings:
if (c_language == clk_c || c_language == clk_objective_c)
flag_const_strings = on;
@@ -869,6 +940,10 @@ c_common_decode_option (argc, argv)
flag_no_nonansi_builtin = !on;
break;
+ case OPT_foperator_names:
+ cpp_opts->operator_names = on;
+ break;
+
case OPT_foptional_diags:
flag_optional_diags = on;
break;
@@ -877,6 +952,10 @@ c_common_decode_option (argc, argv)
flag_permissive = on;
break;
+ case OPT_fpreprocessed:
+ cpp_opts->preprocessed = on;
+ break;
+
case OPT_frepo:
flag_use_repository = on;
if (on)
@@ -887,10 +966,29 @@ c_common_decode_option (argc, argv)
flag_rtti = on;
break;
+ case OPT_fshow_column:
+ cpp_opts->show_column = on;
+ break;
+
case OPT_fstats:
flag_detailed_statistics = on;
break;
+ case OPT_ftabstop:
+ /* Don't recognise -fno-tabstop=. */
+ if (!on)
+ return 0;
+
+ /* It is documented that we silently ignore silly values. */
+ if (*arg)
+ {
+ char *endptr;
+ long tabstop = strtol (arg, &endptr, 10);
+ if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
+ cpp_opts->tabstop = tabstop;
+ }
+ break;
+
case OPT_ftemplate_depth:
max_tinst_depth = read_integral_parameter (arg, argv[0], 0);
break;
@@ -911,6 +1009,17 @@ c_common_decode_option (argc, argv)
flag_gen_declaration = 1;
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. */
+ case OPT_pedantic_errors:
+ cpp_opts->pedantic_errors = 1;
+ /* fall through */
+ case OPT_pedantic:
+ cpp_opts->pedantic = 1;
+ cpp_opts->warn_endif_labels = 1;
+ break;
+
case OPT_print_objc_runtime_info:
print_struct_values = 1;
break;
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index a7ffeb0..3203027 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -1156,34 +1156,7 @@ 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("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("Wno-unused-macros", 0, OPT_Wno_unused_macros) \
- 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("Wunused-macros", 0, OPT_Wunused_macros) \
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) \
- DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
- DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
- DEF_OPT("fshow-column", 0, OPT_fshow_column) \
- DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
DEF_OPT("h", 0, OPT_h) \
DEF_OPT("idirafter", no_dir, OPT_idirafter) \
DEF_OPT("imacros", no_fil, OPT_imacros) \
@@ -1200,8 +1173,6 @@ new_pending_directive (pend, text, handler)
DEF_OPT("nostdinc", 0, OPT_nostdinc) \
DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus) \
DEF_OPT("o", no_fil, OPT_o) \
- DEF_OPT("pedantic", 0, OPT_pedantic) \
- DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors) \
DEF_OPT("remap", 0, OPT_remap) \
DEF_OPT("std=c++98", 0, OPT_std_cplusplus98) \
DEF_OPT("std=c89", 0, OPT_std_c89) \
@@ -1363,31 +1334,6 @@ cpp_handle_option (pfile, argc, argv)
{
case N_OPTS: /* Shut GCC up. */
break;
- case OPT_fno_operator_names:
- CPP_OPTION (pfile, operator_names) = 0;
- break;
- case OPT_fpreprocessed:
- CPP_OPTION (pfile, preprocessed) = 1;
- break;
- case OPT_fno_preprocessed:
- CPP_OPTION (pfile, preprocessed) = 0;
- break;
- case OPT_fshow_column:
- CPP_OPTION (pfile, show_column) = 1;
- break;
- case OPT_fno_show_column:
- CPP_OPTION (pfile, show_column) = 0;
- break;
- case OPT_ftabstop:
- /* Silently ignore empty string, non-longs and silly values. */
- if (arg[0] != '\0')
- {
- char *endptr;
- long tabstop = strtol (arg, &endptr, 10);
- if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
- CPP_OPTION (pfile, tabstop) = tabstop;
- }
- break;
case OPT_w:
CPP_OPTION (pfile, inhibit_warnings) = 1;
break;
@@ -1421,13 +1367,6 @@ cpp_handle_option (pfile, argc, argv)
case OPT_D:
new_pending_directive (pend, arg, cpp_define);
break;
- case OPT_pedantic_errors:
- CPP_OPTION (pfile, pedantic_errors) = 1;
- /* fall through */
- case OPT_pedantic:
- CPP_OPTION (pfile, pedantic) = 1;
- CPP_OPTION (pfile, warn_endif_labels) = 1;
- break;
case OPT_trigraphs:
CPP_OPTION (pfile, trigraphs) = 1;
break;
@@ -1667,77 +1606,6 @@ cpp_handle_option (pfile, argc, argv)
/* Add directory to end of path for includes. */
append_include_chain (pfile, xstrdup (arg), AFTER, 0);
break;
-
- case OPT_Wall:
- CPP_OPTION (pfile, warn_trigraphs) = 1;
- CPP_OPTION (pfile, warn_comments) = 1;
- CPP_OPTION (pfile, warn_num_sign_change) = 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_Wunused_macros:
- CPP_OPTION (pfile, warn_unused_macros) = 1;
- break;
- case OPT_Wno_unused_macros:
- CPP_OPTION (pfile, warn_unused_macros) = 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;
}
}
return i + 1;