aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2020-06-15 19:42:11 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2020-06-15 19:54:01 +0200
commitfb149ebdfee8995ed091f17cd64355ff54e9fb30 (patch)
tree4e4998067c3c8211f0e44cc3138318e98ad4bcdb /gcc/testsuite/gnat.dg
parentb6ab9ecd550227684643b41e9e33a4d3466724d8 (diff)
Fix ICE in verify_sra_access_forest
This fixes an issue with reverse storage order in SRA, which is caught by the built-in verifier in verify_sra_access_forest. The problem is that propagate_subaccesses_from_rhs changes the type of an access from aggregate to scalar and, as discussed elsewhere, this must be done with extra care in the presence of reverse storage order. gcc/ChangeLog * tree-sra.c (propagate_subaccesses_from_rhs): When a non-scalar access on the LHS is replaced with a scalar access, propagate the TYPE_REVERSE_STORAGE_ORDER flag of the type of the original access. gcc/testsuite/ChangeLog * gnat.dg/opt85.ads, gnat.dg/opt85.adb: New test.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/opt85.adb20
-rw-r--r--gcc/testsuite/gnat.dg/opt85.ads27
2 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/opt85.adb b/gcc/testsuite/gnat.dg/opt85.adb
new file mode 100644
index 00000000000..94213a45819
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt85.adb
@@ -0,0 +1,20 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Opt85 is
+
+ function Conversion_Of (Value : Integer) return Data_Type is
+ begin
+ return (Value => Interfaces.Integer_16 (Value));
+ end;
+
+ function Create (Value : Integer) return Record_Type is
+ Rec : constant Record_Type :=
+ (Ada.Finalization.Controlled with
+ Header => (others => False),
+ Data => Conversion_Of (Value));
+ begin
+ return Rec;
+ end;
+
+end Opt85;
diff --git a/gcc/testsuite/gnat.dg/opt85.ads b/gcc/testsuite/gnat.dg/opt85.ads
new file mode 100644
index 00000000000..00b5c284da8
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt85.ads
@@ -0,0 +1,27 @@
+with Ada.Finalization;
+with Interfaces;
+with System;
+
+package Opt85 is
+
+ type Data_Type is record
+ Value : Interfaces.Integer_16;
+ end record;
+ for Data_Type use record
+ Value at 0 range 0 .. 15;
+ end record;
+ for Data_Type'Alignment use 1;
+ for Data_Type'Size use 2 * System.Storage_Unit;
+ for Data_Type'Bit_Order use System.High_Order_First;
+ for Data_Type'Scalar_Storage_Order use System.High_Order_First;
+
+ type Header_Type is array (1 .. 1) of Boolean;
+
+ type Record_Type is new Ada.Finalization.Controlled with record
+ Header : Header_Type;
+ Data : Data_Type;
+ end record;
+
+ function Create (Value : Integer) return Record_Type;
+
+end Opt85;