c-decl.c (store_parm_decls): Make saved_warn_shadow boolean.

* c-decl.c (store_parm_decls): Make saved_warn_shadow boolean.
	* common.opt: Add remaining -W options and -g.
	* diagnostic.c (warnings_are_errors): Remove.
	* flags.h: Make most warning flags boolean.
	* opts.c (common_handle_option): Handle remaining -W options, and -g.
	Move many warning flags from toplev.c, making them boolean.
	* toplev.c: Remove many warning flags.
	(decode_W_option): Remove.
	(decode_g_option): Make extern.  Error on unknown switch.
	(lang_independent_W_options): Use warn_dummy.
	(independent_decode_option): Just handle -f switches now.
	* toplev.h (decode_g_option): New.

From-SVN: r68287
This commit is contained in:
Neil Booth 2003-06-20 22:56:36 +00:00 committed by Neil Booth
parent bdb0f0f5d2
commit e01cc6dc62
8 changed files with 323 additions and 208 deletions

View file

@ -1,3 +1,18 @@
2003-06-20 Neil Booth <neil@daikokuya.co.uk>
* c-decl.c (store_parm_decls): Make saved_warn_shadow boolean.
* common.opt: Add remaining -W options and -g.
* diagnostic.c (warnings_are_errors): Remove.
* flags.h: Make most warning flags boolean.
* opts.c (common_handle_option): Handle remaining -W options, and -g.
Move many warning flags from toplev.c, making them boolean.
* toplev.c: Remove many warning flags.
(decode_W_option): Remove.
(decode_g_option): Make extern. Error on unknown switch.
(lang_independent_W_options): Use warn_dummy.
(independent_decode_option): Just handle -f switches now.
* toplev.h (decode_g_option): New.
2003-06-20 Aldy Hernandez <aldyh@redhat.com>
PR/11092

View file

@ -5719,10 +5719,10 @@ store_parm_decls (void)
/* Nonzero if this definition is written with a prototype. */
int prototype = 0;
int saved_warn_shadow = warn_shadow;
bool saved_warn_shadow = warn_shadow;
/* Don't re-emit shadow warnings. */
warn_shadow = 0;
warn_shadow = false;
if (specparms != 0 && TREE_CODE (specparms) != TREE_LIST)
{

View file

@ -46,12 +46,81 @@ Common
W
Common RejectNegative
Waggregate-return
Common
Wcast-align
Common
Wdeprecated-declarations
Common
Wdisabled-optimization
Common
Werror
Common
Wextra
Common
Winline
Common
Wlarger-than-
Common RejectNegative Joined UInteger
Wmissing-noreturn
Common
Wpacked
Common
Wpadded
Common
Wshadow
Common
Wstrict-aliasing
Common
Wswitch
Common
Wswitch-default
Common
Wswitch-enum
Common
Wsystem-headers
Common
Wuninitialized
Common
Wunreachable-code
Common
Wunused
Common
Wunused-function
Common
Wunused-label
Common
Wunused-parameter
Common
Wunused-value
Common
Wunused-variable
Common
aux-info
Common Separate
@ -70,6 +139,9 @@ Common Joined
dumpbase
Common Separate
g
Common JoinedOrMissing
m
Common Joined

View file

@ -85,7 +85,6 @@ static void diagnostic_action_after_output (diagnostic_context *,
static void real_abort (void) ATTRIBUTE_NORETURN;
extern int rtl_dump_and_exit;
extern int warnings_are_errors;
/* A diagnostic_context surrogate for stderr. */
static diagnostic_context global_diagnostic_context;

View file

@ -77,16 +77,20 @@ extern int mem_report;
/* Don't print warning messages. -w. */
extern int inhibit_warnings;
extern bool inhibit_warnings;
/* Don't suppress warnings from system headers. -Wsystem-headers. */
extern int warn_system_headers;
extern bool warn_system_headers;
/* Do print extra warnings (such as for uninitialized variables).
-W/-Wextra. */
extern int extra_warnings;
extern bool extra_warnings;
/* If -Werror. */
extern bool warnings_are_errors;
/* Nonzero to warn about unused variables, functions et.al. Use
set_Wunused() to update the -Wunused-* flags that correspond to the
@ -94,19 +98,19 @@ extern int extra_warnings;
extern void set_Wunused PARAMS ((int setting));
extern int warn_unused_function;
extern int warn_unused_label;
extern int warn_unused_parameter;
extern int warn_unused_variable;
extern int warn_unused_value;
extern bool warn_unused_function;
extern bool warn_unused_label;
extern bool warn_unused_parameter;
extern bool warn_unused_variable;
extern bool warn_unused_value;
/* Nonzero to warn about code which is never reached. */
extern int warn_notreached;
extern bool warn_notreached;
/* Nonzero means warn if inline function is too large. */
extern int warn_inline;
extern bool warn_inline;
/* Nonzero to warn about variables used before they are initialized. */
@ -114,21 +118,21 @@ extern int warn_uninitialized;
/* Nonzero means warn about all declarations which shadow others. */
extern int warn_shadow;
extern bool warn_shadow;
/* Warn if a switch on an enum, that does not have a default case,
fails to have a case for every enum value. */
extern int warn_switch;
extern bool warn_switch;
/* Warn if a switch does not have a default case. */
extern int warn_switch_default;
extern bool warn_switch_default;
/* Warn if a switch on an enum fails to have a case for every enum
value (regardless of the presence or otherwise of a default case). */
extern int warn_switch_enum;
extern bool warn_switch_enum;
/* Nonzero means warn about function definitions that default the return type
or that use a null return and have a return-type other than void. */
@ -137,47 +141,47 @@ extern int warn_return_type;
/* Warn about functions which might be candidates for attribute noreturn. */
extern int warn_missing_noreturn;
extern bool warn_missing_noreturn;
/* Nonzero means warn about pointer casts that increase the required
alignment of the target type (and might therefore lead to a crash
due to a misaligned access). */
extern int warn_cast_align;
extern bool warn_cast_align;
/* Nonzero means warn about any objects definitions whose size is larger
than N bytes. Also want about function definitions whose returned
values are larger than N bytes. The value N is in `larger_than_size'. */
extern int warn_larger_than;
extern bool warn_larger_than;
extern HOST_WIDE_INT larger_than_size;
/* Warn if a function returns an aggregate,
since there are often incompatible calling conventions for doing this. */
extern int warn_aggregate_return;
extern bool warn_aggregate_return;
/* Warn if packed attribute on struct is unnecessary and inefficient. */
extern int warn_packed;
extern bool warn_packed;
/* Warn when gcc pads a structure to an alignment boundary. */
extern int warn_padded;
extern bool warn_padded;
/* Warn when an optimization pass is disabled. */
extern int warn_disabled_optimization;
extern bool warn_disabled_optimization;
/* Nonzero means warn about uses of __attribute__((deprecated))
declarations. */
extern int warn_deprecated_decl;
extern bool warn_deprecated_decl;
/* Nonzero means warn about constructs which might not be strict
aliasing safe. */
extern int warn_strict_aliasing;
extern bool warn_strict_aliasing;
/* Nonzero if generating code to do profiling. */

View file

@ -41,6 +41,83 @@ bool exit_after_options;
/* If -version. */
bool version_flag;
/* Print various extra warnings. -W/-Wextra. */
bool extra_warnings;
/* Don't print warning messages. -w. */
bool inhibit_warnings;
/* Treat warnings as errors. -Werror. */
bool warnings_are_errors;
/* Warn if a function returns an aggregate, since there are often
incompatible calling conventions for doing this. */
bool warn_aggregate_return;
/* Nonzero means warn about pointer casts that increase the required
alignment of the target type (and might therefore lead to a crash
due to a misaligned access). */
bool warn_cast_align;
/* Nonzero means warn about uses of __attribute__((deprecated))
declarations. */
bool warn_deprecated_decl = true;
/* Warn when an optimization pass is disabled. */
bool warn_disabled_optimization;
/* Nonzero means warn if inline function is too large. */
bool warn_inline;
/* True to warn about any objects definitions whose size is larger
than N bytes. Also want about function definitions whose returned
values are larger than N bytes, where N is `larger_than_size'. */
bool warn_larger_than;
HOST_WIDE_INT larger_than_size;
/* Warn about functions which might be candidates for attribute noreturn. */
bool warn_missing_noreturn;
/* True to warn about code which is never reached. */
bool warn_notreached;
/* Warn if packed attribute on struct is unnecessary and inefficient. */
bool warn_packed;
/* Warn when gcc pads a structure to an alignment boundary. */
bool warn_padded;
/* True means warn about all declarations which shadow others. */
bool warn_shadow;
/* Nonzero means warn about constructs which might not be
strict-aliasing safe. */
bool warn_strict_aliasing;
/* True to warn if a switch on an enum, that does not have a default
case, fails to have a case for every enum value. */
bool warn_switch;
/* Warn if a switch does not have a default case. */
bool warn_switch_default;
/* Warn if a switch on an enum fails to have a case for every enum
value (regardless of the presence or otherwise of a default case). */
bool warn_switch_enum;
/* Don't suppress warnings from system headers. -Wsystem-headers. */
bool warn_system_headers;
/* True to warn about variables used before they are initialized. */
int warn_uninitialized;
/* True to warn about unused variables, functions et.al. */
bool warn_unused_function;
bool warn_unused_label;
bool warn_unused_parameter;
bool warn_unused_variable;
bool warn_unused_value;
/* Hack for cooperation between set_Wunused and set_Wextra. */
static bool maybe_warn_unused_parameter;
@ -136,7 +213,7 @@ find_opt (const char *input, int lang_mask)
return result;
}
/* If ARG is a postive integer made up solely of digits, return its
/* If ARG is a non-negative integer made up solely of digits, return its
value, otherwise return -1. */
static int
integral_argument (const char *arg)
@ -316,14 +393,106 @@ common_handle_option (size_t scode, const char *arg,
set_Wextra (value);
break;
case OPT_Waggregate_return:
warn_aggregate_return = value;
break;
case OPT_Wcast_align:
warn_cast_align = value;
break;
case OPT_Wdeprecated_declarations:
warn_deprecated_decl = value;
case OPT_Wdisabled_optimization:
warn_disabled_optimization = value;
break;
case OPT_Werror:
warnings_are_errors = value;
break;
case OPT_Wextra:
set_Wextra (value);
break;
case OPT_Winline:
warn_inline = value;
break;
case OPT_Wlarger_than_:
larger_than_size = value;
warn_larger_than = value != -1;
break;
case OPT_Wmissing_noreturn:
warn_missing_noreturn = value;
break;
case OPT_Wpacked:
warn_packed = value;
break;
case OPT_Wpadded:
warn_padded = value;
break;
case OPT_Wshadow:
warn_shadow = value;
break;
case OPT_Wstrict_aliasing:
warn_strict_aliasing = value;
break;
case OPT_Wswitch:
warn_switch = value;
break;
case OPT_Wswitch_default:
warn_switch_default = value;
break;
case OPT_Wswitch_enum:
warn_switch_enum = value;
break;
case OPT_Wsystem_headers:
warn_system_headers = value;
break;
case OPT_Wuninitialized:
warn_uninitialized = value;
break;
case OPT_Wunreachable_code:
warn_notreached = value;
break;
case OPT_Wunused:
set_Wunused (value);
break;
case OPT_Wunused_function:
warn_unused_function = value;
break;
case OPT_Wunused_label:
warn_unused_label = value;
break;
case OPT_Wunused_parameter:
warn_unused_parameter = value;
break;
case OPT_Wunused_value:
warn_unused_value = value;
break;
case OPT_Wunused_variable:
warn_unused_variable = value;
break;
case OPT_aux_info:
case OPT_aux_info_:
aux_info_file_name = arg;
@ -351,6 +520,10 @@ common_handle_option (size_t scode, const char *arg,
dump_base_name = arg;
break;
case OPT_g:
decode_g_option (arg);
break;
case OPT_m:
set_target_switch (arg);
break;
@ -380,7 +553,7 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_w:
inhibit_warnings = 1;
inhibit_warnings = true;
break;
}

View file

@ -118,8 +118,6 @@ static void setup_core_dumping (void);
static void compile_file (void);
static int decode_f_option (const char *);
static int decode_W_option (const char *);
static int decode_g_option (const char *);
static unsigned int independent_decode_option (char **);
static int print_single_switch (FILE *, int, int, const char *,
@ -1492,156 +1490,61 @@ target_options[] = TARGET_OPTIONS;
/* Options controlling warnings. */
/* Don't print warning messages. -w. */
int inhibit_warnings = 0;
/* Don't suppress warnings from system headers. -Wsystem-headers. */
int warn_system_headers = 0;
/* Print various extra warnings. -W/-Wextra. */
int extra_warnings = 0;
/* Treat warnings as errors. -Werror. */
int warnings_are_errors = 0;
/* Nonzero to warn about unused variables, functions et.al. */
int warn_unused_function;
int warn_unused_label;
int warn_unused_parameter;
int warn_unused_variable;
int warn_unused_value;
/* Nonzero to warn about code which is never reached. */
int warn_notreached;
/* Nonzero to warn about variables used before they are initialized. */
int warn_uninitialized;
/* Nonzero means warn about all declarations which shadow others. */
int warn_shadow;
/* Warn if a switch on an enum, that does not have a default case,
fails to have a case for every enum value. */
int warn_switch;
/* Warn if a switch does not have a default case. */
int warn_switch_default;
/* Warn if a switch on an enum fails to have a case for every enum
value (regardless of the presence or otherwise of a default case). */
int warn_switch_enum;
/* Nonzero means warn about function definitions that default the return type
or that use a null return and have a return-type other than void. */
int warn_return_type;
/* Nonzero means warn about pointer casts that increase the required
alignment of the target type (and might therefore lead to a crash
due to a misaligned access). */
int warn_cast_align;
/* Nonzero means warn about any objects definitions whose size is larger
than N bytes. Also want about function definitions whose returned
values are larger than N bytes. The value N is in `larger_than_size'. */
int warn_larger_than;
HOST_WIDE_INT larger_than_size;
/* Nonzero means warn if inline function is too large. */
int warn_inline;
/* Warn if a function returns an aggregate,
since there are often incompatible calling conventions for doing this. */
int warn_aggregate_return;
/* Warn if packed attribute on struct is unnecessary and inefficient. */
int warn_packed;
/* Warn when gcc pads a structure to an alignment boundary. */
int warn_padded;
/* Warn when an optimization pass is disabled. */
int warn_disabled_optimization;
/* Warn about functions which might be candidates for attribute noreturn. */
int warn_missing_noreturn;
/* Nonzero means warn about uses of __attribute__((deprecated))
declarations. */
int warn_deprecated_decl = 1;
/* Nonzero means warn about constructs which might not be
strict-aliasing safe. */
int warn_strict_aliasing;
/* Used for the -W options array temporarily. */
static int warn_dummy;
/* Like f_options, but for -W. */
static const lang_independent_options W_options[] =
{
{"unused-function", &warn_unused_function, 1,
{"unused-function", &warn_dummy, 1,
N_("Warn when a function is unused") },
{"unused-label", &warn_unused_label, 1,
{"unused-label", &warn_dummy, 1,
N_("Warn when a label is unused") },
{"unused-parameter", &warn_unused_parameter, 1,
{"unused-parameter", &warn_dummy, 1,
N_("Warn when a function parameter is unused") },
{"unused-variable", &warn_unused_variable, 1,
{"unused-variable", &warn_dummy, 1,
N_("Warn when a variable is unused") },
{"unused-value", &warn_unused_value, 1,
{"unused-value", &warn_dummy, 1,
N_("Warn when an expression value is unused") },
{"system-headers", &warn_system_headers, 1,
{"system-headers", &warn_dummy, 1,
N_("Do not suppress warnings from system headers") },
{"error", &warnings_are_errors, 1,
{"error", &warn_dummy, 1,
N_("Treat all warnings as errors") },
{"shadow", &warn_shadow, 1,
{"shadow", &warn_dummy, 1,
N_("Warn when one local variable shadows another") },
{"switch", &warn_switch, 1,
{"switch", &warn_dummy, 1,
N_("Warn about enumerated switches, with no default, missing a case") },
{"switch-default", &warn_switch_default, 1,
{"switch-default", &warn_dummy, 1,
N_("Warn about enumerated switches missing a default case") },
{"switch-enum", &warn_switch_enum, 1,
{"switch-enum", &warn_dummy, 1,
N_("Warn about all enumerated switches missing a specific case") },
{"aggregate-return", &warn_aggregate_return, 1,
{"aggregate-return", &warn_dummy, 1,
N_("Warn about returning structures, unions or arrays") },
{"cast-align", &warn_cast_align, 1,
{"cast-align", &warn_dummy, 1,
N_("Warn about pointer casts which increase alignment") },
{"unreachable-code", &warn_notreached, 1,
{"unreachable-code", &warn_dummy, 1,
N_("Warn about code that will never be executed") },
{"uninitialized", &warn_uninitialized, 1,
{"uninitialized", &warn_dummy, 1,
N_("Warn about uninitialized automatic variables") },
{"inline", &warn_inline, 1,
{"inline", &warn_dummy, 1,
N_("Warn when an inlined function cannot be inlined") },
{"packed", &warn_packed, 1,
{"packed", &warn_dummy, 1,
N_("Warn when the packed attribute has no effect on struct layout") },
{"padded", &warn_padded, 1,
{"padded", &warn_dummy, 1,
N_("Warn when padding is required to align struct members") },
{"disabled-optimization", &warn_disabled_optimization, 1,
{"disabled-optimization", &warn_dummy, 1,
N_("Warn when an optimization pass is disabled") },
{"deprecated-declarations", &warn_deprecated_decl, 1,
{"deprecated-declarations", &warn_dummy, 1,
N_("Warn about uses of __attribute__((deprecated)) declarations") },
{"missing-noreturn", &warn_missing_noreturn, 1,
{"missing-noreturn", &warn_dummy, 1,
N_("Warn about functions which might be candidates for attribute noreturn") },
{"strict-aliasing", &warn_strict_aliasing, 1,
{"strict-aliasing", &warn_dummy, 1,
N_ ("Warn about code which might break the strict aliasing rules") }
};
@ -4397,48 +4300,6 @@ decode_f_option (const char *arg)
return 1;
}
/* Parse a -W... command line switch. ARG is the value after the -W.
It is safe to access 'ARG - 2' to generate the full switch name.
Return the number of strings consumed. */
static int
decode_W_option (const char *arg)
{
const char *option_value = NULL;
int j;
/* Search for the option in the table of binary W options. */
for (j = ARRAY_SIZE (W_options); j--;)
{
if (!strcmp (arg, W_options[j].string))
{
*W_options[j].variable = W_options[j].on_value;
return 1;
}
if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
&& ! strcmp (arg + 3, W_options[j].string))
{
*W_options[j].variable = ! W_options[j].on_value;
return 1;
}
}
if ((option_value = skip_leading_substring (arg, "id-clash-")))
warning ("-Wid-clash-LEN is no longer supported");
else if ((option_value = skip_leading_substring (arg, "larger-than-")))
{
larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
warn_larger_than = larger_than_size != -1;
}
else
return 0;
return 1;
}
/* Indexed by enum debug_info_type. */
const char *const debug_type_names[] =
{
@ -4449,7 +4310,7 @@ const char *const debug_type_names[] =
It is safe to access 'ARG - 2' to generate the full switch name.
Return the number of strings consumed. */
static int
void
decode_g_option (const char *arg)
{
static unsigned level = 0;
@ -4560,9 +4421,7 @@ ignoring option `%s' due to invalid debug level specification",
}
if (! da->arg)
return 0;
return 1;
warning ("`-g%s': unknown or unsupported -g option", arg);
}
/* Decode the first argument in the argv as a language-independent option.
@ -4578,20 +4437,10 @@ independent_decode_option (char **argv)
arg++;
switch (*arg)
{
default:
return 0;
if (*arg == 'f')
return decode_f_option (arg + 1);
case 'f':
return decode_f_option (arg + 1);
case 'g':
return decode_g_option (arg + 1);
case 'W':
return decode_W_option (arg + 1);
}
return 0;
}
/* Decode -m switches. */

View file

@ -120,6 +120,9 @@ extern void set_fast_math_flags (int);
/* Handle -d switch. */
extern void decode_d_option (const char *);
/* Handle -g switch. */
extern void decode_g_option (const char *);
/* Return true iff flags are set as if -ffast-math. */
extern bool fast_math_flags_set_p (void);