+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ada-lang.c (ada_language_data): Remove la_range_check
+ initializer.
+ * c-lang.c (c_language_data): Likewise.
+ (cplus_language_data): Likewise.
+ (asm_language_data): Likewise.
+ (minimal_language_data): Likewise.
+ * d-lang.c (d_language_data): Likewise.
+ * f-lang.c (f_language_data): Likewise.
+ (f_language::range_checking_on_by_default): New member function.
+ * go-lang.c (go_language_data): Remove la_range_check initializer.
+ * language.c (enum range_mode): Moved here from language.h.
+ (range_mode): Made static.
+ (show_range_command): Update to use
+ range_checking_on_by_default.
+ (set_range_command): Likewise.
+ (set_range_case): Likewise.
+ (unknown_language_data): Remove la_range_check initializer.
+ (auto_language_data): Likewise.
+ * language.h (range_mode): Delete. Enum definition moved to
+ language.c.
+ (language_data): Remove la_range_check field.
+ (language_defn::range_checking_on_by_default): New member
+ function.
+ * m2-lang.c (m2_language_data): Remove la_range_check initializer.
+ (m2_language::range_checking_on_by_default): New member function.
+ * objc-lang.c (objc_language_data): Remove la_range_check
+ initializer.
+ * opencl-lang.c (opencl_language_data): Likewise.
+ * p-lang.c (pascal_language_data): Likewise.
+ (pascal_language::range_checking_on_by_default): New member
+ function.
+ * rust-lang.c (rust_language_data): Remove la_range_check
+ initializer.
+ (rust_language::range_checking_on_by_default): New member
+ function.
+
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
* dwarf2/read.c (dwarf2_physname): Remove special case for
extern const struct language_data ada_language_data =
{
- range_check_off,
case_sensitive_on, /* Yes, Ada is case-insensitive, but
that's not quite what this means. */
array_row_major,
extern const struct language_data c_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
extern const struct language_data cplus_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
extern const struct language_data asm_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
extern const struct language_data minimal_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
extern const struct language_data d_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
extern const struct language_data f_language_data =
{
- range_check_on,
case_sensitive_off,
array_column_major,
macro_expansion_no,
bool c_style_arrays_p () const override
{ return false; }
+ /* See language.h. */
+
+ bool range_checking_on_by_default () const override
+ { return true; }
+
protected:
/* See language.h. */
extern const struct language_data go_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
static void set_range_case (void);
+/* range_mode ==
+ range_mode_auto: range_check set automatically to default of language.
+ range_mode_manual: range_check set manually by user. */
+
+enum range_mode
+ {
+ range_mode_auto, range_mode_manual
+ };
+
/* The current (default at startup) state of type and range checking.
(If the modes are set to "auto", though, these are changed based
on the default language at startup, and then again based on the
language of the first source file. */
-enum range_mode range_mode = range_mode_auto;
+static enum range_mode range_mode = range_mode_auto;
enum range_check range_check = range_check_off;
enum case_mode case_mode = case_mode_auto;
enum case_sensitivity case_sensitivity = case_sensitive_on;
fprintf_filtered (gdb_stdout, _("Range checking is \"%s\".\n"),
value);
- if (range_check != current_language->la_range_check)
+ if (range_check == range_check_warn
+ || ((range_check == range_check_on)
+ != current_language->range_checking_on_by_default ()))
warning (_("the current range check setting "
"does not match the language.\n"));
}
internal_error (__FILE__, __LINE__,
_("Unrecognized range check setting: \"%s\""), range);
}
- if (range_check != current_language->la_range_check)
+ if (range_check == range_check_warn
+ || ((range_check == range_check_on)
+ != current_language->range_checking_on_by_default ()))
warning (_("the current range check setting "
"does not match the language.\n"));
}
set_range_case (void)
{
if (range_mode == range_mode_auto)
- range_check = current_language->la_range_check;
+ range_check = (current_language->range_checking_on_by_default ()
+ ? range_check_on : range_check_off);
if (case_mode == case_mode_auto)
case_sensitivity = current_language->la_case_sensitivity;
extern const struct language_data unknown_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
extern const struct language_data auto_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */
-/* range_mode ==
- range_mode_auto: range_check set automatically to default of language.
- range_mode_manual: range_check set manually by user. */
-
-extern enum range_mode
- {
- range_mode_auto, range_mode_manual
- }
-range_mode;
-
/* range_check ==
range_check_on: Ranges are checked in GDB expressions, producing errors.
range_check_warn: Ranges are checked, producing warnings.
struct language_data
{
- /* Default range checking. */
-
- enum range_check la_range_check;
-
/* Default case sensitivity. */
enum case_sensitivity la_case_sensitivity;
virtual bool store_sym_names_in_linkage_form_p () const
{ return false; }
+ /* Default range checking preference. The return value from this
+ function provides the automatic setting for 'set check range'. As a
+ consequence a user is free to override this setting if they want. */
+
+ virtual bool range_checking_on_by_default () const
+ { return false; }
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
extern const struct language_data m2_language_data =
{
- range_check_on,
case_sensitive_on,
array_row_major,
macro_expansion_no,
char string_lower_bound () const override
{ return 0; }
+
+ /* See language.h. */
+
+ bool range_checking_on_by_default () const override
+ { return true; }
};
/* Single instance of the M2 language. */
extern const struct language_data objc_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
/* Constant data representing the OpenCL language. */
extern const struct language_data opencl_language_data =
{
- range_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
extern const struct language_data pascal_language_data =
{
- range_check_on,
case_sensitive_on,
array_row_major,
macro_expansion_no,
const char *name_of_this () const override
{ return "this"; }
+
+ /* See language.h. */
+
+ bool range_checking_on_by_default () const override
+ { return true; }
};
/* Single instance of the Pascal language class. */
extern const struct language_data rust_language_data =
{
- range_check_on,
case_sensitive_on,
array_row_major,
macro_expansion_no,
&& rust_slice_type_p (type)
&& strcmp (type->name (), "&str") == 0));
}
+
+ /* See language.h. */
+
+ bool range_checking_on_by_default () const override
+ { return true; }
};
/* Single instance of the Rust language class. */