aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-05-13 11:15:08 +0200
committerEric Botcazou <ebotcazou@adacore.com>2022-05-13 11:19:01 +0200
commit7b844206ec51931d0a81aa4e4fa3b62f6ecef0ca (patch)
tree13319be8c4b929b89715cafc316236e6273a7800 /gcc/testsuite/gnat.dg
parentc77e4873b14bd84fc6715db8980ce14886b28906 (diff)
downloadgcc-7b844206ec51931d0a81aa4e4fa3b62f6ecef0ca.zip
gcc-7b844206ec51931d0a81aa4e4fa3b62f6ecef0ca.tar.gz
gcc-7b844206ec51931d0a81aa4e4fa3b62f6ecef0ca.tar.bz2
Fix wrong SRA with VIEW_CONVERT_EXPR and reverse SSO
Most cases of VIEW_CONVERT_EXPRs involving reverse scalar storage order are disqualified for SRA because they are storage_order_barrier_p, but you can still have a VIEW_CONVERT_EXPR to a regular composite type being applied to a component of a record type with reverse scalar storage order. In this case the bypass for !useless_type_conversion_p in sra_modify_assign, albeit already heavily guarded, triggers and may generate wrong code, so the patch makes sure that it does only when the SSO is the same on both side. gcc/ * tree-sra.cc (sra_modify_assign): Check that scalar storage order is the same on the LHS and RHS before rewriting one with the model of the other. gcc/testsuite/ * gnat.dg/sso17.adb: New test.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/sso17.adb34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/sso17.adb b/gcc/testsuite/gnat.dg/sso17.adb
new file mode 100644
index 0000000..ed57580
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/sso17.adb
@@ -0,0 +1,34 @@
+-- { dg-do run }
+-- { dg-options "-gnatws -O" }
+
+with System;
+
+procedure SSO17 is
+
+ type My_Float is new Float range 0.0 .. 359.99;
+
+ type Rec is record
+ Az : My_Float;
+ El : My_Float;
+ end record;
+ for Rec'Bit_Order use System.High_Order_First;
+ for Rec'Scalar_Storage_Order use System.High_Order_First;
+
+ R : Rec;
+
+ procedure Is_True (B : Boolean);
+ pragma No_Inline (Is_True);
+
+ procedure Is_True (B : Boolean) is
+ begin
+ if not B then
+ raise Program_Error;
+ end if;
+ end;
+
+begin
+ R := (Az => 1.1, El => 2.2);
+ Is_True (R.Az'Valid);
+ R := (Az => 3.3, El => 4.4);
+ Is_True (R.Az'Valid);
+end;