aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2014-02-19 11:07:31 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2014-02-19 12:07:31 +0100
commite7cff5af6f0cde046419d93873b92a9290076ef9 (patch)
tree6d4de55376186332f5b77ffd5bd41c07c06dfa37
parenta767d69b628706fb1c4986232b00ccb61a911ebe (diff)
downloadgcc-e7cff5af6f0cde046419d93873b92a9290076ef9.zip
gcc-e7cff5af6f0cde046419d93873b92a9290076ef9.tar.gz
gcc-e7cff5af6f0cde046419d93873b92a9290076ef9.tar.bz2
exp_util.adb (Side_Effect_Free): Scalar if expressions can be SEF.
2014-02-19 Robert Dewar <dewar@adacore.com> * exp_util.adb (Side_Effect_Free): Scalar if expressions can be SEF. From-SVN: r207892
-rw-r--r--gcc/ada/ChangeLog4
-rw-r--r--gcc/ada/exp_util.adb21
2 files changed, 18 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index dba833b..6418758 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,9 @@
2014-02-19 Robert Dewar <dewar@adacore.com>
+ * exp_util.adb (Side_Effect_Free): Scalar if expressions can be SEF.
+
+2014-02-19 Robert Dewar <dewar@adacore.com>
+
* exp_util.adb: Update comments.
2014-02-19 Doug Rupp <rupp@adacore.com>
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index ff18d08..cab1774 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -7675,6 +7675,9 @@ package body Exp_Util is
Name_Req : Boolean := False;
Variable_Ref : Boolean := False) return Boolean
is
+ Typ : constant Entity_Id := Etype (N);
+ -- Result type of the expression
+
function Safe_Prefixed_Reference (N : Node_Id) return Boolean;
-- The argument N is a construct where the Prefix is dereferenced if it
-- is an access type and the result is a variable. The call returns True
@@ -7919,7 +7922,7 @@ package body Exp_Util is
elsif VM_Target /= No_VM
and then not Comes_From_Source (N)
and then Nkind (Parent (N)) = N_Object_Renaming_Declaration
- and then Is_Class_Wide_Type (Etype (N))
+ and then Is_Class_Wide_Type (Typ)
then
return True;
end if;
@@ -7981,12 +7984,16 @@ package body Exp_Util is
Side_Effect_Free
(First (Parameter_Associations (N)), Name_Req, Variable_Ref);
- -- An IF expression is side effect free if its components are all
- -- side effect free (conditions and then actions and else actions).
+ -- An IF expression is side effect free if it's of a scalar type, and
+ -- all its components are all side effect free (conditions and then
+ -- actions and else actions). We restrict to scalar types, since it
+ -- is annoying to deal with things like (if A then B else C)'First
+ -- where the type involved is a string type.
- -- when N_If_Expression =>
- -- return Side_Effect_Free (Expressions (N), Name_Req, Variable_Ref);
- -- commented out for now, caused some crashes ???
+ when N_If_Expression =>
+ return Is_Scalar_Type (Typ)
+ and then
+ Side_Effect_Free (Expressions (N), Name_Req, Variable_Ref);
-- An indexed component is side effect free if it is a side
-- effect free prefixed reference and all the indexing
@@ -8014,7 +8021,7 @@ package body Exp_Util is
when N_Selected_Component =>
if Nkind (Parent (N)) = N_Explicit_Dereference
- and then Has_Non_Standard_Rep (Designated_Type (Etype (N)))
+ and then Has_Non_Standard_Rep (Designated_Type (Typ))
then
return False;
else