aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-07-16 11:07:32 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-20 03:21:34 -0400
commit1b93e420fc10f0eaeb2b09d9b86c8defb5b459a4 (patch)
tree248397daf9f92bef00d1172a4347ff5794404341
parentd3c2ce8e4e059e4350cf9f917c9cca4a0e5821db (diff)
downloadgcc-1b93e420fc10f0eaeb2b09d9b86c8defb5b459a4.zip
gcc-1b93e420fc10f0eaeb2b09d9b86c8defb5b459a4.tar.gz
gcc-1b93e420fc10f0eaeb2b09d9b86c8defb5b459a4.tar.bz2
[Ada] Fix internal error on bit-aligned component of function call
gcc/ada/ * exp_util.adb (Remove_Side_Effects): Always generate a renaming that is handled by the front-end in the case of an indexed or a selected component whose prefix has a nonstandard representation.
-rw-r--r--gcc/ada/exp_util.adb37
1 files changed, 21 insertions, 16 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 5083817..2c08ea9 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -11530,7 +11530,26 @@ package body Exp_Util is
Insert_Action (Exp, E);
end if;
- -- For expressions that denote names, we can use a renaming scheme.
+ -- If this is a packed array component or a selected component with a
+ -- nonstandard representation, we cannot generate a reference because
+ -- the component may be unaligned, so we must use a renaming and this
+ -- renaming must be handled by the front end, as the back end may balk
+ -- at the nonstandard representation (see Exp_Ch2.Expand_Renaming).
+
+ elsif Nkind (Exp) in N_Indexed_Component | N_Selected_Component
+ and then Has_Non_Standard_Rep (Etype (Prefix (Exp)))
+ then
+ Def_Id := Build_Temporary (Loc, 'R', Exp);
+ Res := New_Occurrence_Of (Def_Id, Loc);
+
+ Insert_Action (Exp,
+ Make_Object_Renaming_Declaration (Loc,
+ Defining_Identifier => Def_Id,
+ Subtype_Mark => New_Occurrence_Of (Exp_Type, Loc),
+ Name => Relocate_Node (Exp)));
+
+ -- For an expression that denotes a name, we can use a renaming scheme
+ -- that is handled by the back end, instead of the front end as above.
-- This is needed for correctness in the case of a volatile object of
-- a nonvolatile type because the Make_Reference call of the "default"
-- approach would generate an illegal access value (an access value
@@ -11553,21 +11572,7 @@ package body Exp_Util is
Subtype_Mark => New_Occurrence_Of (Exp_Type, Loc),
Name => Relocate_Node (Exp)));
- -- If this is a packed reference, or a selected component with
- -- a nonstandard representation, a reference to the temporary
- -- will be replaced by a copy of the original expression (see
- -- Exp_Ch2.Expand_Renaming). Otherwise the temporary must be
- -- elaborated by gigi, and is of course not to be replaced in-line
- -- by the expression it renames, which would defeat the purpose of
- -- removing the side effect.
-
- if Nkind (Exp) in N_Selected_Component | N_Indexed_Component
- and then Has_Non_Standard_Rep (Etype (Prefix (Exp)))
- then
- null;
- else
- Set_Is_Renaming_Of_Object (Def_Id, False);
- end if;
+ Set_Is_Renaming_Of_Object (Def_Id, False);
-- Avoid generating a variable-sized temporary, by generating the
-- reference just for the function call. The transformation could be