upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
/* for VLAs number of array elements is 0 */
- if (upper_bound.get_unsigned_value() == 0)
+ if (upper_bound.get_unsigned_value() == 0 && nelems == 0)
is_infinite = true;
subrange.reset(new array_type_def::subrange_type(rdr->env(),
test-read-ctf/test-array-mdimension.abi \
test-read-ctf/test-array-mdimension.c \
test-read-ctf/test-array-mdimension.o \
+test-read-ctf/test-array-size.abi \
+test-read-ctf/test-array-size.c \
+test-read-ctf/test-array-size.o \
\
test-annotate/test0.abi \
test-annotate/test1.abi \
--- /dev/null
+<abi-corpus version='2.1' path='data/test-read-ctf/test-array-size.o'>
+ <elf-variable-symbols>
+ <elf-symbol name='bar' size='1' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ <elf-symbol name='baz' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ <elf-symbol name='foo' size='2' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ </elf-variable-symbols>
+ <abi-instr address-size='64' language='LANG_C'>
+ <type-decl name='char' size-in-bits='8' id='type-id-1'/>
+ <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='8' id='type-id-2'>
+ <subrange length='1' type-id='type-id-3' id='type-id-4'/>
+ </array-type-def>
+ <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='16' id='type-id-5'>
+ <subrange length='2' type-id='type-id-3' id='type-id-6'/>
+ </array-type-def>
+ <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-7'>
+ <subrange length='infinite' type-id='type-id-3' id='type-id-8'/>
+ </array-type-def>
+ <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/>
+ <var-decl name='bar' type-id='type-id-2' mangled-name='bar' visibility='default' elf-symbol-id='bar'/>
+ <var-decl name='baz' type-id='type-id-7' mangled-name='baz' visibility='default' elf-symbol-id='baz'/>
+ <var-decl name='foo' type-id='type-id-5' mangled-name='foo' visibility='default' elf-symbol-id='foo'/>
+ </abi-instr>
+</abi-corpus>
--- /dev/null
+/* gcc -gctf -c test-array-size.c -o test-array-size.o */
+char foo[2];
+char bar[1];
+char baz[0];
<array-type-def dimensions='1' type-id='type-id-2' size-in-bits='448' alignment-in-bits='64' id='type-id-3'>
<subrange length='7' type-id='type-id-4' id='type-id-5'/>
</array-type-def>
- <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-6'>
- <subrange length='infinite' type-id='type-id-4' id='type-id-7'/>
+ <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='8' id='type-id-6'>
+ <subrange length='1' type-id='type-id-4' id='type-id-7'/>
</array-type-def>
<type-decl name='double' size-in-bits='64' id='type-id-8'/>
<array-type-def dimensions='2' type-id='type-id-8' size-in-bits='960' id='type-id-9'>
"output/test-read-ctf/test-array-mdimension.abi",
"--ctf",
},
+ {
+ "data/test-read-ctf/test-array-size.o",
+ "",
+ "",
+ SEQUENCE_TYPE_ID_STYLE,
+ "data/test-read-ctf/test-array-size.abi",
+ "output/test-read-ctf/test-array-size.abi",
+ "--ctf",
+ },
// This should be the last entry.
{NULL, NULL, NULL, SEQUENCE_TYPE_ID_STYLE, NULL, NULL, NULL}
};