diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-07-08 08:13:04 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-08 08:13:04 +0000 |
commit | 5291985c00302036cc6d5932fdffb9acab3043cf (patch) | |
tree | 5a8235daf9a8a352f258c29c49aa04a99448cb63 /gcc/ada | |
parent | b91cdf756caafddf48433e6f93c4cc0049d292f8 (diff) | |
download | gcc-5291985c00302036cc6d5932fdffb9acab3043cf.zip gcc-5291985c00302036cc6d5932fdffb9acab3043cf.tar.gz gcc-5291985c00302036cc6d5932fdffb9acab3043cf.tar.bz2 |
[Ada] Crash on named actual in postcondition for generic subprogram
This patch fixes a crash on compiling the postcondtion for a generic
subprogram, when the postcondition is a call with both positional and
named parameter associations.
2019-07-08 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch13.adb (Analyze_Aspect_Specifications): For a
pre/postcondition of a generic subprogram declaration, do not
use Relocate_Node on the aspect expression to construct the
corresponding attribute specification, to prevent tree anomalies
when the expression is a call with named actual parameters.
gcc/testsuite/
* gnat.dg/predicate9.adb: New testcase.
From-SVN: r273201
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/sem_ch13.adb | 28 |
2 files changed, 30 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9a86909..d651ff0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2019-07-08 Ed Schonberg <schonberg@adacore.com> + + * sem_ch13.adb (Analyze_Aspect_Specifications): For a + pre/postcondition of a generic subprogram declaration, do not + use Relocate_Node on the aspect expression to construct the + corresponding attribute specification, to prevent tree anomalies + when the expression is a call with named actual parameters. + 2019-07-08 Javier Miranda <miranda@adacore.com> * sem_attr.adb (Analyze_Attribute [Attribute_Size]): For pragmas diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index b62e297..8467f75 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -3495,12 +3495,28 @@ package body Sem_Ch13 is -- because subsequent visibility analysis of the aspect -- depends on this sharing. This should be cleaned up??? - Make_Aitem_Pragma - (Pragma_Argument_Associations => New_List ( - Make_Pragma_Argument_Association (Eloc, - Chars => Name_Check, - Expression => Relocate_Node (Expr))), - Pragma_Name => Pname); + -- If the context is generic or involves ASIS, we want + -- to preserve the original tree, and simply share it + -- between aspect and generated attribute. This parallels + -- what is done in sem_prag.adb (see Get_Argument). + + declare + New_Expr : Node_Id; + + begin + if ASIS_Mode or else Inside_A_Generic then + New_Expr := Expr; + else + New_Expr := Relocate_Node (Expr); + end if; + + Make_Aitem_Pragma + (Pragma_Argument_Associations => New_List ( + Make_Pragma_Argument_Association (Eloc, + Chars => Name_Check, + Expression => New_Expr)), + Pragma_Name => Pname); + end; -- Add message unless exception messages are suppressed |