+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
* valops.c (value_repeat): Fix incorrect argument name in comment.
&ada_exp_descriptor,
true, /* la_store_sym_names_in_linkage_form_p */
ada_op_print_tab, /* expression operators for printing */
- 1, /* String lower bound */
&ada_varobj_ops,
};
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&c_varobj_ops,
};
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&cplus_varobj_ops,
};
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
d_op_print_tab, /* Expression operators for printing. */
- 0, /* String lower bound. */
&default_varobj_ops,
};
&exp_descriptor_f,
false, /* la_store_sym_names_in_linkage_form_p */
f_op_print_tab, /* expression operators for printing */
- 1, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
go_op_print_tab, /* Expression operators for printing. */
- 0, /* String lower bound. */
&default_varobj_ops,
};
&exp_descriptor_standard,
true, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_standard,
false, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
const struct op_print *la_op_print_tab;
- /* Index to use for extracting the first element of a string. */
- char string_lower_bound;
-
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
};
virtual bool c_style_arrays_p () const
{ return true; }
+ /* Return the index to use for extracting the first element of a string,
+ or as the lower bound when creating a new string. The default of
+ choosing 0 or 1 based on C_STYLE_ARRAYS_P works for all currently
+ supported languages except Modula-2. */
+
+ virtual char string_lower_bound () const
+ { return c_style_arrays_p () ? 0 : 1; }
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
&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,
};
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. */
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
objc_op_print_tab, /* Expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_opencl,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
pascal_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
&exp_descriptor_rust,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
value_cstring (const char *ptr, ssize_t len, struct type *char_type)
{
struct value *val;
- int lowbound = current_language->string_lower_bound;
+ int lowbound = current_language->string_lower_bound ();
ssize_t highbound = len / TYPE_LENGTH (char_type);
struct type *stringtype
= lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
value_string (const char *ptr, ssize_t len, struct type *char_type)
{
struct value *val;
- int lowbound = current_language->string_lower_bound;
+ int lowbound = current_language->string_lower_bound ();
ssize_t highbound = len / TYPE_LENGTH (char_type);
struct type *stringtype
= lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
struct value *
allocate_repeat_value (struct type *type, int count)
{
- int low_bound = current_language->string_lower_bound; /* ??? */
+ /* Despite the fact that we are really creating an array of TYPE here, we
+ use the string lower bound as the array lower bound. This seems to
+ work fine for now. */
+ int low_bound = current_language->string_lower_bound ();
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
struct type *array_type