diff options
author | pmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-17 14:10:12 +0000 |
---|---|---|
committer | pmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-17 14:10:12 +0000 |
commit | 584cdd4fbf89854054b1a2174f2ec8f3be953199 (patch) | |
tree | 147811576da6971191a0556e3c237b728b185cf6 /gcc/ada/gcc-interface/misc.c | |
parent | 4b4c965405b05718925271963db6a1e33ebd0dee (diff) |
DWARF: create a macro for max dimensions for array descr. lang. hook
The array descriptor language hook can hold the description of a limited
number of array dimensions. This macro will ease preventing overflow in
front-ends.
gcc/ada/ChangeLog:
* gcc-interface/misc.c (gnat_get_array_descr_info): When the
array has more dimensions than the language hook can handle,
fall back to a nested arrays description. Handle context-less
array types.
gcc/ChangeLog:
* dwarf2out.h (DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN): New macro.
(struct array_descr_info): Use it for the dimensions array's
size.
* dwarf2out.c (gen_type_die_with_usage): Check that the array
descr. language hook does not return an array with more
dimensions that it should.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231766 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
-rw-r--r-- | gcc/ada/gcc-interface/misc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 279e5fcaa37f..891ca3f338c0 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -856,7 +856,20 @@ gnat_get_array_descr_info (const_tree type, struct array_descr_info *info) break; last_dimen = dimen; } + info->ndimensions = i; + + /* Too many dimensions? Give up generating proper description: yield instead + nested arrays. Note that in this case, this hook is invoked once on each + intermediate array type: be consistent and output nested arrays for all + dimensions. */ + if (info->ndimensions > DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN + || TYPE_MULTI_ARRAY_P (first_dimen)) + { + info->ndimensions = 1; + last_dimen = first_dimen; + } + info->element_type = TREE_TYPE (last_dimen); /* Now iterate over all dimensions in source-order and fill the info @@ -881,7 +894,8 @@ gnat_get_array_descr_info (const_tree type, struct array_descr_info *info) expressions: arrays that are constrained by record discriminants and XUA types. */ const bool is_xua_type = - (TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE + (TYPE_CONTEXT (first_dimen) != NULL_TREE + && TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE && contains_placeholder_p (TYPE_MIN_VALUE (index_type))); if (is_xua_type && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL) |