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
This commit is contained in:
Zack Weinberg 2002-06-07 22:24:30 +00:00 committed by Zack Weinberg
parent 3522a91b80
commit 09e77dee59
6 changed files with 104 additions and 62 deletions

View File

@ -1,3 +1,15 @@
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>
* gengtype-yacc.y (optionseqopt): Add the ending `;' to the action.

View File

@ -502,7 +502,7 @@ c_decode_option (argc, argv)
{ "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"))
{

View File

@ -1,3 +1,7 @@
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)
* decl2.c (flag_use_cxa_atexit): Set to DEFAULT_USE_CXA_ATEXIT.

View File

@ -479,7 +479,7 @@ cxx_decode_option (argc, argv)
int strings_processed;
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')
{

View File

@ -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;
}

View File

@ -515,7 +515,7 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
structure reliable. Options processing is not completed until you
call cpp_finish_options. */
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 *));
/* This function reads the file, but does not start preprocessing. It