diff options
author | Bob Duff <duff@adacore.com> | 2020-12-07 08:16:34 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-04-28 05:37:56 -0400 |
commit | cbd743fe0942e91eaa5e788ad21ac660f686a0de (patch) | |
tree | f2798f10f10afdd1baab9c8a36d210bc44f32f7e | |
parent | 3cb4256addca89ff6d6c47ed3ea53499d5b97a52 (diff) | |
download | gcc-cbd743fe0942e91eaa5e788ad21ac660f686a0de.zip gcc-cbd743fe0942e91eaa5e788ad21ac660f686a0de.tar.gz gcc-cbd743fe0942e91eaa5e788ad21ac660f686a0de.tar.bz2 |
[Ada] Incorrect error with Default_Value on private/modular type
gcc/ada/
* exp_ch3.adb (Simple_Init_Defaulted_Type): Simplify the code,
and always use OK_Convert_To, rather than Unchecked_Convert_To
and Convert_To.
-rw-r--r-- | gcc/ada/exp_ch3.adb | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index e0040ed..b916aef 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -8597,35 +8597,28 @@ package body Exp_Ch3 is -------------------------------- function Simple_Init_Defaulted_Type return Node_Id is - Subtyp : constant Entity_Id := First_Subtype (Typ); + Subtyp : Entity_Id := First_Subtype (Typ); begin - -- Use the Sloc of the context node when constructing the initial - -- value because the expression of Default_Value may come from a - -- different unit. Updating the Sloc will result in accurate error - -- diagnostics. - -- When the first subtype is private, retrieve the expression of the -- Default_Value from the underlying type. if Is_Private_Type (Subtyp) then - return - Unchecked_Convert_To - (Typ => Typ, - Expr => - New_Copy_Tree - (Source => Default_Aspect_Value (Full_View (Subtyp)), - New_Sloc => Loc)); - - else - return - Convert_To - (Typ => Typ, - Expr => - New_Copy_Tree - (Source => Default_Aspect_Value (Subtyp), - New_Sloc => Loc)); + Subtyp := Full_View (Subtyp); end if; + + -- Use the Sloc of the context node when constructing the initial + -- value because the expression of Default_Value may come from a + -- different unit. Updating the Sloc will result in accurate error + -- diagnostics. + + return + OK_Convert_To + (Typ => Typ, + Expr => + New_Copy_Tree + (Source => Default_Aspect_Value (Subtyp), + New_Sloc => Loc)); end Simple_Init_Defaulted_Type; ----------------------------------------- |