summaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@codesourcery.com>2002-06-07 22:24:30 +0000
committerZack Weinberg <zack@gcc.gnu.org>2002-06-07 22:24:30 +0000
commit09e77dee592f5bdb33b3e3ccd48fdba631d26139 (patch)
tree7a1bf70d67c5edb93d24792709314b561db24b09 /gcc/cppinit.c
parent3522a91b8029058d4b7a06d8f5b4932f6a35dfc4 (diff)
downloadgcc-09e77dee592f5bdb33b3e3ccd48fdba631d26139.tar.gz
cppinit.c (COMMAND_LINE_OPTIONS): Give all relevant -W options their own entries.
* cppinit.c (COMMAND_LINE_OPTIONS): Give all relevant -W options their own entries. (parse_option): Clarify comment. (cpp_handle_option): Remove 'ignore' parameter and OPT_W special case. Replace if/strcmp chain for -W options with use of new OPT_* entries for them. (cpp_handle_options): Update to match. * cpplib.h: Remove last parameter to cpp_handle_option from prototype. * c-decl.c, cp/decl2.c: Update call to cpp_handle_option. From-SVN: r54352
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c144
1 files changed, 85 insertions, 59 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 9d6a105852a..1bb323f9988 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -1152,7 +1152,25 @@ 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("W", no_arg, OPT_W) /* arg optional */ \
+ 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("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("d", no_arg, OPT_d) \
DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
@@ -1228,10 +1246,7 @@ static const struct cl_option cl_options[] =
command-line matches. Returns its index in the option array,
negative on failure. Complications arise since some options can be
suffixed with an argument, and multiple complete matches can occur,
- e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
- accept options beginning with -W that we do not recognise, but not
- to swallow any subsequent command line argument; this is handled as
- special cases in cpp_handle_option. */
+ e.g. -pedantic and -pedantic-errors. */
static int
parse_option (input)
const char *input;
@@ -1290,14 +1305,12 @@ parse_option (input)
/* Handle one command-line option in (argc, argv).
Can be called multiple times, to handle multiple sets of options.
- If ignore is non-zero, this will ignore unrecognized -W* options.
Returns number of strings consumed. */
int
-cpp_handle_option (pfile, argc, argv, ignore)
+cpp_handle_option (pfile, argc, argv)
cpp_reader *pfile;
int argc;
char **argv;
- int ignore;
{
int i = 0;
struct cpp_pending *pend = CPP_OPTION (pfile, pending);
@@ -1329,11 +1342,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
if (cl_options[opt_index].msg)
{
arg = &argv[i][cl_options[opt_index].opt_len + 1];
-
- /* Yuk. Special case for -W as it must not swallow
- up any following argument. If this becomes common, add
- another field to the cl_options table. */
- if (arg[0] == '\0' && opt_code != OPT_W)
+ if (arg[0] == '\0')
{
arg = argv[++i];
if (!arg)
@@ -1665,51 +1674,68 @@ cpp_handle_option (pfile, argc, argv, ignore)
/* Add directory to end of path for includes. */
append_include_chain (pfile, xstrdup (arg), AFTER, 0);
break;
- case OPT_W:
- /* Silently ignore unrecognised options. */
- if (!strcmp (argv[i], "-Wall"))
- {
- CPP_OPTION (pfile, warn_trigraphs) = 1;
- CPP_OPTION (pfile, warn_comments) = 1;
- }
- else if (!strcmp (argv[i], "-Wtraditional"))
- CPP_OPTION (pfile, warn_traditional) = 1;
- else if (!strcmp (argv[i], "-Wtrigraphs"))
- CPP_OPTION (pfile, warn_trigraphs) = 1;
- else if (!strcmp (argv[i], "-Wcomment"))
- CPP_OPTION (pfile, warn_comments) = 1;
- else if (!strcmp (argv[i], "-Wcomments"))
- CPP_OPTION (pfile, warn_comments) = 1;
- else if (!strcmp (argv[i], "-Wundef"))
- CPP_OPTION (pfile, warn_undef) = 1;
- else if (!strcmp (argv[i], "-Wimport"))
- CPP_OPTION (pfile, warn_import) = 1;
- else if (!strcmp (argv[i], "-Werror"))
- CPP_OPTION (pfile, warnings_are_errors) = 1;
- else if (!strcmp (argv[i], "-Wsystem-headers"))
- CPP_OPTION (pfile, warn_system_headers) = 1;
- else if (!strcmp (argv[i], "-Wendif-labels"))
- CPP_OPTION (pfile, warn_endif_labels) = 1;
- else if (!strcmp (argv[i], "-Wno-traditional"))
- CPP_OPTION (pfile, warn_traditional) = 0;
- else if (!strcmp (argv[i], "-Wno-trigraphs"))
- CPP_OPTION (pfile, warn_trigraphs) = 0;
- else if (!strcmp (argv[i], "-Wno-comment"))
- CPP_OPTION (pfile, warn_comments) = 0;
- else if (!strcmp (argv[i], "-Wno-comments"))
- CPP_OPTION (pfile, warn_comments) = 0;
- else if (!strcmp (argv[i], "-Wno-undef"))
- CPP_OPTION (pfile, warn_undef) = 0;
- else if (!strcmp (argv[i], "-Wno-import"))
- CPP_OPTION (pfile, warn_import) = 0;
- else if (!strcmp (argv[i], "-Wno-error"))
- CPP_OPTION (pfile, warnings_are_errors) = 0;
- else if (!strcmp (argv[i], "-Wno-system-headers"))
- CPP_OPTION (pfile, warn_system_headers) = 0;
- else if (!strcmp (argv[i], "-Wno-endif-labels"))
- CPP_OPTION (pfile, warn_endif_labels) = 0;
- else if (! ignore)
- return i;
+
+ case OPT_Wall:
+ CPP_OPTION (pfile, warn_trigraphs) = 1;
+ CPP_OPTION (pfile, warn_comments) = 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_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;
}
}
@@ -1731,7 +1757,7 @@ cpp_handle_options (pfile, argc, argv)
for (i = 0; i < argc; i += strings_processed)
{
- strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
+ strings_processed = cpp_handle_option (pfile, argc - i, argv + i);
if (strings_processed == 0)
break;
}