/* 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
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. */
/* 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. */
/* 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. */
/* 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;
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)
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;
dump_base_name = arg;
break;
+ case OPT_g:
+ decode_g_option (arg);
+ break;
+
case OPT_m:
set_target_switch (arg);
break;
break;
case OPT_w:
- inhibit_warnings = 1;
+ inhibit_warnings = true;
break;
}
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 *,
/* 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") }
};
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[] =
{
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;
}
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.
arg++;
- switch (*arg)
- {
- default:
- return 0;
-
- case 'f':
- return decode_f_option (arg + 1);
+ if (*arg == '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. */