aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-lang.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-07-05 09:29:34 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-09-16 10:16:48 +0100
commit22c12a6c70a0bf1c292478436f12df0a2d84c2a2 (patch)
treeeb8f23e76fedac0151280623ebe9d055819b34d3 /gdb/m2-lang.c
parent1c236ddd45b182b6f4895b276183cdd8382d3e1b (diff)
downloadgdb-22c12a6c70a0bf1c292478436f12df0a2d84c2a2.zip
gdb-22c12a6c70a0bf1c292478436f12df0a2d84c2a2.tar.gz
gdb-22c12a6c70a0bf1c292478436f12df0a2d84c2a2.tar.bz2
gdb: Convert language_data::string_lower_bound to a method
Convert language_data::string_lower_bound member variable to a virtual method language_defn::string_lower_bound. Over all of the languages we currently support there are currently only two values for the lower bound, 0 or 1. I noticed that in all cases, if a language has C style arrays then the lower bound is 0, otherwise the lower bound is 1. So the default for the virtual method in language.h makes use of this, which means languages don't have to worry about providing a string_lower_bound method at all. Except for Modula2. This language is defined to not have C style arrays, but has a string_lower_bound index of 0, this behaviour is maintained after this commit by having Modula2 be the only language that overrides the string_lower_bound method. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove string_lower_bound 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. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Remove string_lower_bound field. (language_defn::string_lower_bound): New member function. * m2-lang.c (m2_language_data): Remove string_lower_bound initializer. (m2_language::string_lower_bound): New member function. * objc-lang.c (objc_language_data): Remove string_lower_bound initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * valops.c (value_cstring): Update call to string_lower_bound. (value_string): Likewise. * value.c (allocate_repeated_value): Likewise.
Diffstat (limited to 'gdb/m2-lang.c')
-rw-r--r--gdb/m2-lang.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 9dd5577..7bd9e71 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -206,7 +206,6 @@ extern const struct language_data m2_language_data =
&exp_descriptor_modula2,
false, /* la_store_sym_names_in_linkage_form_p */
m2_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
@@ -440,6 +439,12 @@ public:
bool c_style_arrays_p () const override
{ return false; }
+
+ /* See language.h. Despite not having C-style arrays, Modula-2 uses 0
+ for its string lower bounds. */
+
+ char string_lower_bound () const override
+ { return 0; }
};
/* Single instance of the M2 language. */