diff options
author | Ed Schonberg <schonberg@adacore.com> | 2021-05-05 08:50:23 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-07-06 14:46:53 +0000 |
commit | f55784f8adc6033639840c609329d7b1facb2e71 (patch) | |
tree | 39e8f11dff37a81960157f0e5a25cd2c0f68824a | |
parent | 68c27b2a702d073e21cd41c0080c849f7a4804ca (diff) | |
download | gcc-f55784f8adc6033639840c609329d7b1facb2e71.zip gcc-f55784f8adc6033639840c609329d7b1facb2e71.tar.gz gcc-f55784f8adc6033639840c609329d7b1facb2e71.tar.bz2 |
[Ada] Improper predicate check on view conversion
gcc/ada/
* exp_ch4.adb (Expand_N_Type_Conversion): If the conversion is
the name of an assignment operation do not apply predicate check
to it prior to the assignment.
-rw-r--r-- | gcc/ada/exp_ch4.adb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index d608a30..21b2c22 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -12748,7 +12748,16 @@ package body Exp_Ch4 is -- guard is necessary to prevent infinite recursions when we generate -- internal conversions for the purpose of checking predicates. - if Predicate_Enabled (Target_Type) + -- A view conversion of a tagged object is an object and can appear + -- in an assignment context, in which case no predicate check applies + -- to the now-dead value. + + if Nkind (Parent (N)) = N_Assignment_Statement + and then N = Name (Parent (N)) + then + null; + + elsif Predicate_Enabled (Target_Type) and then Target_Type /= Operand_Type and then Comes_From_Source (N) then |