aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/specs
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-05-19 09:00:11 +0200
committerEric Botcazou <ebotcazou@adacore.com>2023-05-19 09:02:17 +0200
commit24dcf65dabf48b4d33b7f2d4c68f369627b61bdc (patch)
treeaa4e72cfdb2332f23a458ac253431724e8003b6e /gcc/testsuite/gnat.dg/specs
parentc3db10967411be9c17f0ef01f13e82a947b7e12f (diff)
downloadgcc-24dcf65dabf48b4d33b7f2d4c68f369627b61bdc.zip
gcc-24dcf65dabf48b4d33b7f2d4c68f369627b61bdc.tar.gz
gcc-24dcf65dabf48b4d33b7f2d4c68f369627b61bdc.tar.bz2
Fix internal error on small array with negative lower bound
Ada supports arrays with negative indices, although the internal index type is sizetype like in other languages, which is unsigned. This means that negative values are represented by very large numbers, which works with a bit of care. This plugs a small loophole in output_constructor_bitfield. gcc/ * varasm.cc (output_constructor_bitfield): Call tree_to_uhwi instead of tree_to_shwi on array indices. Minor tweaks. gcc/testsuite/ * gnat.dg/specs/array6.ads: New test.
Diffstat (limited to 'gcc/testsuite/gnat.dg/specs')
-rw-r--r--gcc/testsuite/gnat.dg/specs/array6.ads14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/specs/array6.ads b/gcc/testsuite/gnat.dg/specs/array6.ads
new file mode 100644
index 0000000..72f8824
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/array6.ads
@@ -0,0 +1,14 @@
+-- { dg-do compile }
+
+package Array6 is
+
+ type Range_Type is range -10 .. 10;
+ type Array_Type is array (Range_Type range <> ) of Short_Short_Integer;
+
+ type Record_Type is record
+ A : Array_Type(-2..4);
+ end record ;
+
+ Rec : Record_Type := (A => (others => -1));
+
+end Array6;