dw_attr_node *upper_bound_at;
dw_die_ref array_index_type;
- uint32_t array_num_elements;
+ unsigned HOST_WIDE_INT array_num_elements;
if (dw_get_die_tag (c) == DW_TAG_subrange_type)
{
if (upper_bound_at
&& AT_class (upper_bound_at) == dw_val_class_unsigned_const)
/* This is the upper bound index. */
- array_num_elements = get_AT_unsigned (c, DW_AT_upper_bound) + 1;
+ array_num_elements = AT_unsigned (get_AT (c, DW_AT_upper_bound)) + 1;
else if (get_AT (c, DW_AT_count))
- array_num_elements = get_AT_unsigned (c, DW_AT_count);
+ array_num_elements = AT_unsigned (get_AT (c, DW_AT_count));
else
{
/* This is a VLA of some kind. */
else
gcc_unreachable ();
+ if (array_num_elements > UINT32_MAX)
+ {
+ /* The array cannot be encoded in CTF. TBD_CTF_REPRESENTATION_LIMIT. */
+ return gen_ctf_unknown_type (ctfc);
+ }
+
/* Ok, mount and register the array type. Note how the array
type we register here is the type of the elements in
subsequent "dimensions", if there are any. */
--- /dev/null
+/* CTF generation for array which cannot be encoded in CTF.
+
+ CTF encoding uses a uint32 for number of elements in an array which
+ means there is a hard upper limit on sizes of arrays which can be
+ represented. Arrays with too many elements are encoded with
+ CTF_K_UNKNOWN to indicate that they cannot be represented. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gctf -dA" } */
+
+int rep[0xffffffff];
+int unrep[0x100000000];
+
+/* One dimension can be represented, other cannot.
+ Result is a (representable) array with unknown element type. */
+int unrepdim [0xab][0x100000007];
+
+/* Two CTF_K_ARRAY, one (shared) CTF_K_UNKNOWN. */
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+/* { dg-final { scan-assembler-times "0x2000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]+0xffffffff\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]+0xab\[\t \]+\[^\n\]*cta_nelems" 1 } } */