aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2019-12-16 10:33:54 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-12-16 10:33:54 +0000
commit90393d3ca7fe7547777473f4b197792f1cb3fca9 (patch)
tree821a6b8acb86adc767c5f4b93f61910f7b03211f /gcc/ada
parent4a1872632c20e4b93d5d3214505470966c0bebb4 (diff)
downloadgcc-90393d3ca7fe7547777473f4b197792f1cb3fca9.zip
gcc-90393d3ca7fe7547777473f4b197792f1cb3fca9.tar.gz
gcc-90393d3ca7fe7547777473f4b197792f1cb3fca9.tar.bz2
[Ada] Crash on conversion in branch of if-expression
2019-12-16 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * checks.adb (Apply_Float_Conversion_Check): Use node of type conversion and not its parent, when inserting the declaration for the temporary that hold the result of the conversion. Previously the declaration was inserted above the parent of the conversion, apparently as a small optimization for the subsequent traversal in Insert_Actions. Unfortunately a similar optimization takes place in Insert_Actions, assuming that the insertion point must be above the expression that creates the actions to insert. This is not correct in the presence of conditional expressions (i.e. since Ada2012), where the insertion must be in the list of actions attached to the current alternative. From-SVN: r279422
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog15
-rw-r--r--gcc/ada/checks.adb12
2 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index aa97043..e0f821b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,18 @@
+2019-12-16 Ed Schonberg <schonberg@adacore.com>
+
+ * checks.adb (Apply_Float_Conversion_Check): Use node of type
+ conversion and not its parent, when inserting the declaration
+ for the temporary that hold the result of the conversion.
+ Previously the declaration was inserted above the parent of the
+ conversion, apparently as a small optimization for the
+ subsequent traversal in Insert_Actions. Unfortunately a similar
+ optimization takes place in Insert_Actions, assuming that the
+ insertion point must be above the expression that creates the
+ actions to insert. This is not correct in the presence of
+ conditional expressions (i.e. since Ada2012), where the
+ insertion must be in the list of actions attached to the current
+ alternative.
+
2019-12-16 Bob Duff <duff@adacore.com>
* sem_attr.adb (Analyze_Attribute): Use Known_RM_Size. But we
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 9ca1cf0..6b910fd 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -2067,7 +2067,17 @@ package body Checks is
Apply_Float_Conversion_Check (Ck_Node, Target_Base);
Set_Etype (Temp, Target_Base);
- Insert_Action (Parent (Par),
+ -- Note : previously the declaration was inserted above
+ -- the parent of the conversion, apparently as a small
+ -- optimization for the subequent traversal in Insert_
+ -- Actions. Unfortunately a similar optimization takes
+ -- place in Insert_Actions, assuming that the insertion
+ -- point must be above the expression that creates actions.
+ -- This is not correct in the presence of conditional
+ -- expressions, where the insertion must be in the
+ -- list of asctions attached to the current alternative.
+
+ Insert_Action (Par,
Make_Object_Declaration (Loc,
Defining_Identifier => Temp,
Object_Definition => New_Occurrence_Of (Target_Typ, Loc),