static gcc_type compile_cplus_convert_array (compile_cplus_instance *instance, struct type *type) { struct type *range = TYPE_INDEX_TYPE (type); gcc_type element_type = instance->convert_type (TYPE_TARGET_TYPE (type)); if (TYPE_LOW_BOUND_KIND (range) != PROP_CONST) { const char *s = _("array type with non-constant" " lower bound is not supported"); return instance->plugin ().error (s); } if (TYPE_LOW_BOUND (range) != 0) { const char *s = _("cannot convert array type with " "non-zero lower bound to C"); return instance->plugin ().error (s); } if (TYPE_HIGH_BOUND_KIND (range) == PROP_LOCEXPR || TYPE_HIGH_BOUND_KIND (range) == PROP_LOCLIST) { if (TYPE_VECTOR (type)) { const char *s = _("variably-sized vector type is not supported"); return instance->plugin ().error (s); } std::string upper_bound = c_get_range_decl_name (&TYPE_RANGE_DATA (range)->high); return instance->plugin ().build_vla_array_type (element_type, upper_bound.c_str ()); } else { LONGEST low_bound, high_bound, count; if (get_array_bounds (type, &low_bound, &high_bound) == 0) count = -1; else { gdb_assert (low_bound == 0); /* Ensured above. */ count = high_bound + 1; } if (TYPE_VECTOR (type)) return instance->plugin ().build_vector_type (element_type, count); return instance->plugin ().build_array_type (element_type, count); } }
void c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, int show, int passed_a_ptr, int demangled_args, const struct type_print_options *flags) { if (type == 0) return; if (TYPE_NAME (type) && show <= 0) return; QUIT; switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: { LONGEST low_bound, high_bound; int is_vector = TYPE_VECTOR (type); if (passed_a_ptr) fprintf_filtered (stream, ")"); fprintf_filtered (stream, (is_vector ? " __attribute__ ((vector_size(" : "[")); /* Bounds are not yet resolved, print a bounds placeholder instead. */ if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST) fprintf_filtered (stream, "variable length"); else if (get_array_bounds (type, &low_bound, &high_bound)) fprintf_filtered (stream, "%s", plongest (high_bound - low_bound + 1)); fprintf_filtered (stream, (is_vector ? ")))" : "]")); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 0, 0, flags); } break; case TYPE_CODE_MEMBERPTR: c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 0, 0, flags); break; case TYPE_CODE_METHODPTR: fprintf_filtered (stream, ")"); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 0, 0, flags); break; case TYPE_CODE_PTR: case TYPE_CODE_REF: c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 1, 0, flags); break; case TYPE_CODE_METHOD: case TYPE_CODE_FUNC: if (passed_a_ptr) fprintf_filtered (stream, ")"); if (!demangled_args) c_type_print_args (type, stream, 0, current_language->la_language, flags); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, passed_a_ptr, 0, flags); break; case TYPE_CODE_TYPEDEF: c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, passed_a_ptr, 0, flags); break; case TYPE_CODE_UNDEF: case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: case TYPE_CODE_ENUM: case TYPE_CODE_INT: case TYPE_CODE_FLT: case TYPE_CODE_VOID: case TYPE_CODE_ERROR: case TYPE_CODE_CHAR: case TYPE_CODE_BOOL: case TYPE_CODE_SET: case TYPE_CODE_RANGE: case TYPE_CODE_STRING: case TYPE_CODE_COMPLEX: case TYPE_CODE_NAMESPACE: case TYPE_CODE_DECFLOAT: /* These types do not need a suffix. They are listed so that gcc -Wall will report types that may not have been considered. */ break; default: error (_("type not handled in c_type_print_varspec_suffix()")); break; } }