Commit 09e77dee by Zack Weinberg Committed by Zack Weinberg

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
parent 3522a91b
2002-06-07 Zack Weinberg <zack@codesourcery.com>
* 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: Update call to cpp_handle_option.
2002-06-07 Akim Demaille <akim@epita.fr> 2002-06-07 Akim Demaille <akim@epita.fr>
* gengtype-yacc.y (optionseqopt): Add the ending `;' to the action. * gengtype-yacc.y (optionseqopt): Add the ending `;' to the action.
......
...@@ -502,7 +502,7 @@ c_decode_option (argc, argv) ...@@ -502,7 +502,7 @@ c_decode_option (argc, argv)
{ "write-strings", &flag_const_strings } { "write-strings", &flag_const_strings }
}; };
strings_processed = cpp_handle_option (parse_in, argc, argv, 0); strings_processed = cpp_handle_option (parse_in, argc, argv);
if (!strcmp (p, "-fhosted") || !strcmp (p, "-fno-freestanding")) if (!strcmp (p, "-fhosted") || !strcmp (p, "-fno-freestanding"))
{ {
......
2002-06-07 Zack Weinberg <zack@codesourcery.com>
* decl2.c: Update call to cpp_handle_option.
2002-06-07 H.J. Lu (hjl@gnu.org) 2002-06-07 H.J. Lu (hjl@gnu.org)
* decl2.c (flag_use_cxa_atexit): Set to DEFAULT_USE_CXA_ATEXIT. * decl2.c (flag_use_cxa_atexit): Set to DEFAULT_USE_CXA_ATEXIT.
......
...@@ -479,7 +479,7 @@ cxx_decode_option (argc, argv) ...@@ -479,7 +479,7 @@ cxx_decode_option (argc, argv)
int strings_processed; int strings_processed;
const char *p = argv[0]; const char *p = argv[0];
strings_processed = cpp_handle_option (parse_in, argc, argv, 0); strings_processed = cpp_handle_option (parse_in, argc, argv);
if (p[0] == '-' && p[1] == 'f') if (p[0] == '-' && p[1] == 'f')
{ {
......
...@@ -1152,7 +1152,25 @@ new_pending_directive (pend, text, handler) ...@@ -1152,7 +1152,25 @@ new_pending_directive (pend, text, handler)
DEF_OPT("MT", no_tgt, OPT_MT) \ DEF_OPT("MT", no_tgt, OPT_MT) \
DEF_OPT("P", 0, OPT_P) \ DEF_OPT("P", 0, OPT_P) \
DEF_OPT("U", no_mac, OPT_U) \ 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("d", no_arg, OPT_d) \
DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \ DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \ DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
...@@ -1228,10 +1246,7 @@ static const struct cl_option cl_options[] = ...@@ -1228,10 +1246,7 @@ static const struct cl_option cl_options[] =
command-line matches. Returns its index in the option array, command-line matches. Returns its index in the option array,
negative on failure. Complications arise since some options can be negative on failure. Complications arise since some options can be
suffixed with an argument, and multiple complete matches can occur, suffixed with an argument, and multiple complete matches can occur,
e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to e.g. -pedantic and -pedantic-errors. */
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. */
static int static int
parse_option (input) parse_option (input)
const char *input; const char *input;
...@@ -1290,14 +1305,12 @@ parse_option (input) ...@@ -1290,14 +1305,12 @@ parse_option (input)
/* Handle one command-line option in (argc, argv). /* Handle one command-line option in (argc, argv).
Can be called multiple times, to handle multiple sets of options. 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. */ Returns number of strings consumed. */
int int
cpp_handle_option (pfile, argc, argv, ignore) cpp_handle_option (pfile, argc, argv)
cpp_reader *pfile; cpp_reader *pfile;
int argc; int argc;
char **argv; char **argv;
int ignore;
{ {
int i = 0; int i = 0;
struct cpp_pending *pend = CPP_OPTION (pfile, pending); struct cpp_pending *pend = CPP_OPTION (pfile, pending);
...@@ -1329,11 +1342,7 @@ cpp_handle_option (pfile, argc, argv, ignore) ...@@ -1329,11 +1342,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
if (cl_options[opt_index].msg) if (cl_options[opt_index].msg)
{ {
arg = &argv[i][cl_options[opt_index].opt_len + 1]; arg = &argv[i][cl_options[opt_index].opt_len + 1];
if (arg[0] == '\0')
/* 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)
{ {
arg = argv[++i]; arg = argv[++i];
if (!arg) if (!arg)
...@@ -1665,51 +1674,68 @@ cpp_handle_option (pfile, argc, argv, ignore) ...@@ -1665,51 +1674,68 @@ cpp_handle_option (pfile, argc, argv, ignore)
/* Add directory to end of path for includes. */ /* Add directory to end of path for includes. */
append_include_chain (pfile, xstrdup (arg), AFTER, 0); append_include_chain (pfile, xstrdup (arg), AFTER, 0);
break; break;
case OPT_W:
/* Silently ignore unrecognised options. */ case OPT_Wall:
if (!strcmp (argv[i], "-Wall")) CPP_OPTION (pfile, warn_trigraphs) = 1;
{ CPP_OPTION (pfile, warn_comments) = 1;
CPP_OPTION (pfile, warn_trigraphs) = 1; break;
CPP_OPTION (pfile, warn_comments) = 1;
} case OPT_Wtraditional:
else if (!strcmp (argv[i], "-Wtraditional")) CPP_OPTION (pfile, warn_traditional) = 1;
CPP_OPTION (pfile, warn_traditional) = 1; break;
else if (!strcmp (argv[i], "-Wtrigraphs")) case OPT_Wno_traditional:
CPP_OPTION (pfile, warn_trigraphs) = 1; CPP_OPTION (pfile, warn_traditional) = 0;
else if (!strcmp (argv[i], "-Wcomment")) break;
CPP_OPTION (pfile, warn_comments) = 1;
else if (!strcmp (argv[i], "-Wcomments")) case OPT_Wtrigraphs:
CPP_OPTION (pfile, warn_comments) = 1; CPP_OPTION (pfile, warn_trigraphs) = 1;
else if (!strcmp (argv[i], "-Wundef")) break;
CPP_OPTION (pfile, warn_undef) = 1; case OPT_Wno_trigraphs:
else if (!strcmp (argv[i], "-Wimport")) CPP_OPTION (pfile, warn_trigraphs) = 0;
CPP_OPTION (pfile, warn_import) = 1; break;
else if (!strcmp (argv[i], "-Werror"))
CPP_OPTION (pfile, warnings_are_errors) = 1; case OPT_Wcomment:
else if (!strcmp (argv[i], "-Wsystem-headers")) case OPT_Wcomments:
CPP_OPTION (pfile, warn_system_headers) = 1; CPP_OPTION (pfile, warn_comments) = 1;
else if (!strcmp (argv[i], "-Wendif-labels")) break;
CPP_OPTION (pfile, warn_endif_labels) = 1; case OPT_Wno_comment:
else if (!strcmp (argv[i], "-Wno-traditional")) case OPT_Wno_comments:
CPP_OPTION (pfile, warn_traditional) = 0; CPP_OPTION (pfile, warn_comments) = 0;
else if (!strcmp (argv[i], "-Wno-trigraphs")) break;
CPP_OPTION (pfile, warn_trigraphs) = 0;
else if (!strcmp (argv[i], "-Wno-comment")) case OPT_Wundef:
CPP_OPTION (pfile, warn_comments) = 0; CPP_OPTION (pfile, warn_undef) = 1;
else if (!strcmp (argv[i], "-Wno-comments")) break;
CPP_OPTION (pfile, warn_comments) = 0; case OPT_Wno_undef:
else if (!strcmp (argv[i], "-Wno-undef")) CPP_OPTION (pfile, warn_undef) = 0;
CPP_OPTION (pfile, warn_undef) = 0; break;
else if (!strcmp (argv[i], "-Wno-import"))
CPP_OPTION (pfile, warn_import) = 0; case OPT_Wimport:
else if (!strcmp (argv[i], "-Wno-error")) CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, warnings_are_errors) = 0; break;
else if (!strcmp (argv[i], "-Wno-system-headers")) case OPT_Wno_import:
CPP_OPTION (pfile, warn_system_headers) = 0; CPP_OPTION (pfile, warn_import) = 0;
else if (!strcmp (argv[i], "-Wno-endif-labels")) break;
CPP_OPTION (pfile, warn_endif_labels) = 0;
else if (! ignore) case OPT_Wendif_labels:
return i; 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; break;
} }
} }
...@@ -1731,7 +1757,7 @@ cpp_handle_options (pfile, argc, argv) ...@@ -1731,7 +1757,7 @@ cpp_handle_options (pfile, argc, argv)
for (i = 0; i < argc; i += strings_processed) 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) if (strings_processed == 0)
break; break;
} }
......
...@@ -515,7 +515,7 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *)); ...@@ -515,7 +515,7 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
structure reliable. Options processing is not completed until you structure reliable. Options processing is not completed until you
call cpp_finish_options. */ call cpp_finish_options. */
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **)); extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **, int)); extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_post_options PARAMS ((cpp_reader *)); extern void cpp_post_options PARAMS ((cpp_reader *));
/* This function reads the file, but does not start preprocessing. It /* This function reads the file, but does not start preprocessing. It
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment