+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ada-lang.c (ada_language_data): Remove c_style_arrays
+ initializer.
+ (ada_language::c_style_arrays_p): New member fuction.
+ * c-lang.c (c_language_data): Remove c_style_arrays
+ initializer.
+ (cplus_language_data): Likewise.
+ (asm_language_data): Likewise.
+ (minimal_language_data): Likewise.
+ * d-lang.c (d_language_data): Likewise.
+ * eval.c (ptrmath_type_p): Update call to c_style_arrays_p.
+ * f-lang.c (f_language_data): Remove c_style_arrays initializer.
+ (f_language::c_style_arrays_p): New member function.
+ * go-lang.c (go_language_data): Remove c_style_arrays initializer.
+ * infcall.c (value_arg_coerce): Update call to c_style_arrays_p.
+ * language.c (unknown_language_data): Remove c_style_arrays
+ initializer.
+ (auto_language_data): Likewise.
+ * language.h (language_data): Remove c_style_arrays field.
+ (language_defn::c_style_arrays_p): New member function.
+ * m2-lang.c (m2_language_data): Remove c_style_arrays initializer.
+ (m2_language::c_style_arrays_p): New member function.
+ * objc-lang.c (objc_language_data): Remove c_style_arrays
+ initializer.
+ * opencl-lang.c (opencl_language_data): Likewise.
+ * p-lang.c (pascal_language_data): Likewise.
+ * rust-lang.c (rust_language_data): Likewise.
+ * valarith.c (value_subscript): Update call to c_style_arrays_p,
+ and update local variable to a bool.
+ * valops.c (value_cast): Update call to c_style_arrays_p.
+ (value_array): Likewise.
+ * value.c (coerce_array): Likewise.
+
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Remove la_language initializer.
&ada_exp_descriptor,
true, /* la_store_sym_names_in_linkage_form_p */
ada_op_print_tab, /* expression operators for printing */
- 0, /* c-style arrays */
1, /* String lower bound */
&ada_varobj_ops,
};
const char *struct_too_deep_ellipsis () const override
{ return "(...)"; }
+ /* See language.h. */
+
+ bool c_style_arrays_p () const override
+ { return false; }
+
protected:
/* See language.h. */
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 1, /* c-style arrays */
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 */
- 1, /* c-style arrays */
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 */
- 1, /* c-style arrays */
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 */
- 1, /* c-style arrays */
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. */
- 1, /* C-style arrays. */
0, /* String lower bound. */
&default_varobj_ops,
};
return 1;
case TYPE_CODE_ARRAY:
- return type->is_vector () ? 0 : lang->c_style_arrays;
+ return type->is_vector () ? 0 : lang->c_style_arrays_p ();
default:
return 0;
&exp_descriptor_f,
false, /* la_store_sym_names_in_linkage_form_p */
f_op_print_tab, /* expression operators for printing */
- 0, /* arrays are first-class (not c-style) */
1, /* String lower bound */
&default_varobj_ops,
};
const char *struct_too_deep_ellipsis () const override
{ return "(...)"; }
+ /* See language.h. */
+
+ bool c_style_arrays_p () const override
+ { return false; }
+
protected:
/* See language.h. */
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
go_op_print_tab, /* Expression operators for printing. */
- 1, /* C-style arrays. */
0, /* String lower bound. */
&default_varobj_ops,
};
/* Arrays are coerced to pointers to their first element, unless
they are vectors, in which case we want to leave them alone,
because they are passed by value. */
- if (current_language->c_style_arrays)
+ if (current_language->c_style_arrays_p ())
if (!type->is_vector ())
type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
break;
&exp_descriptor_standard,
true, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
- 1, /* c-style arrays */
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 */
- 1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
};
const struct op_print *la_op_print_tab;
- /* Zero if the language has first-class arrays. True if there are no
- array values, and array objects decay to pointers, as in C. */
-
- char c_style_arrays;
-
/* Index to use for extracting the first element of a string. */
char string_lower_bound;
virtual const char *name_of_this () const
{ return nullptr; }
+ /* Return false if the language has first-class arrays. Return true if
+ there are no array values, and array objects decay to pointers, as in
+ C. The default is true as currently most supported languages behave
+ in this manor. */
+
+ virtual bool c_style_arrays_p () const
+ { return true; }
+
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, /* arrays are first-class (not c-style) */
0, /* String lower bound */
&default_varobj_ops,
};
return false;
}
+
+ /* See language.h. */
+
+ bool c_style_arrays_p () const override
+ { return false; }
};
/* 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 */
- 1, /* C-style arrays */
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 */
- 1, /* c-style arrays */
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 */
- 1, /* c-style arrays */
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 */
- 1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
};
struct value *
value_subscript (struct value *array, LONGEST index)
{
- int c_style = current_language->c_style_arrays;
+ bool c_style = current_language->c_style_arrays_p ();
struct type *tarray;
array = coerce_ref (array);
if (VALUE_LVAL (array) != lval_memory)
return value_subscripted_rvalue (array, index, lowerbound);
- if (c_style == 0)
+ if (!c_style)
{
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, index, lowerbound);
if (upperbound > -1)
warning (_("array or string index out of range"));
/* fall doing C stuff */
- c_style = 1;
+ c_style = true;
}
index -= lowerbound;
}
}
- if (current_language->c_style_arrays
+ if (current_language->c_style_arrays_p ()
&& type2->code () == TYPE_CODE_ARRAY
&& !type2->is_vector ())
arg2 = value_coerce_array (arg2);
arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]),
lowbound, highbound);
- if (!current_language->c_style_arrays)
+ if (!current_language->c_style_arrays_p ())
{
val = allocate_value (arraytype);
for (idx = 0; idx < nelem; idx++)
switch (type->code ())
{
case TYPE_CODE_ARRAY:
- if (!type->is_vector () && current_language->c_style_arrays)
+ if (!type->is_vector () && current_language->c_style_arrays_p ())
arg = value_coerce_array (arg);
break;
case TYPE_CODE_FUNC: