aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_intr.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2015-11-12 12:38:28 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2015-11-12 12:38:28 +0100
commit311014705a3cf42caf7446caa95f4e4a34fce9be (patch)
treefa339846e5282acd562105c9ad0be87609fa21cf /gcc/ada/exp_intr.adb
parent3095f7c6ebd5863450d82f11a5ca25c7b06581fe (diff)
downloadgcc-311014705a3cf42caf7446caa95f4e4a34fce9be.zip
gcc-311014705a3cf42caf7446caa95f4e4a34fce9be.tar.gz
gcc-311014705a3cf42caf7446caa95f4e4a34fce9be.tar.bz2
[multiple changes]
2015-11-12 Gary Dismukes <dismukes@adacore.com> * exp_ch5.adb, sem_ch3.adb, exp_util.ads, inline.adb, freeze.adb, sem_util.adb, sem_util.ads, par-ch6.adb, sem_elab.adb: Minor reformatting and a typo fix. 2015-11-12 Ed Schonberg <schonberg@adacore.com> * sem_ch12.adb (Preanalyze_Actuals): Add guard on use of Incomplete_Actuals, which are only stored for a package instantiation, in order to place the instance in the body of the enclosing unit. 2015-11-12 Ed Schonberg <schonberg@adacore.com> * exp_intr.adb: Add legality checks on calls to a Generic_Dispatching_Constructor: the given tag must be defined, it cannot be the tag of an abstract type, and its accessibility level must not be greater than that of the constructor. 2015-11-12 Ed Schonberg <schonberg@adacore.com> * sem_ch4.adb (Try_Container_Indexing, Constant_Indexing_OK): If the context is an overloaded call, assume that Constant_Indexing is not OK if an interpretation has an assignable parameter corresponding to the indexing expression. 2015-11-12 Jerome Lambourg <lambourg@adacore.com> * init.c (__gnat_error_handler): Force the SPE bit of the MSR when executing on e500v2 CPU. 2015-11-12 Hristian Kirtchev <kirtchev@adacore.com> * sem_prag.adb (Analyze_Constituent): Stop the analysis after detecting a misplaced constituent as this is a critical error. From-SVN: r230239
Diffstat (limited to 'gcc/ada/exp_intr.adb')
-rw-r--r--gcc/ada/exp_intr.adb44
1 files changed, 43 insertions, 1 deletions
diff --git a/gcc/ada/exp_intr.adb b/gcc/ada/exp_intr.adb
index bbdcf77..a76486b 100644
--- a/gcc/ada/exp_intr.adb
+++ b/gcc/ada/exp_intr.adb
@@ -311,6 +311,31 @@ package body Exp_Intr is
Remove_Side_Effects (Tag_Arg);
+ -- Check that we have a proper tag
+
+ Insert_Action (N,
+ Make_Implicit_If_Statement (N,
+ Condition => Make_Op_Eq (Loc,
+ Left_Opnd => New_Copy_Tree (Tag_Arg),
+ Right_Opnd => New_Occurrence_Of (RTE (RE_No_Tag), Loc)),
+
+ Then_Statements => New_List (
+ Make_Raise_Statement (Loc,
+ New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
+
+ -- Check that it is not the tag of an abstract type
+
+ Insert_Action (N,
+ Make_Implicit_If_Statement (N,
+ Condition => Make_Function_Call (Loc,
+ Name =>
+ New_Occurrence_Of (RTE (RE_Type_Is_Abstract), Loc),
+ Parameter_Associations => New_List (New_Copy_Tree (Tag_Arg))),
+
+ Then_Statements => New_List (
+ Make_Raise_Statement (Loc,
+ New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
+
-- The subprogram is the third actual in the instantiation, and is
-- retrieved from the corresponding renaming declaration. However,
-- freeze nodes may appear before, so we retrieve the declaration
@@ -324,6 +349,22 @@ package body Exp_Intr is
Act_Constr := Entity (Name (Act_Rename));
Result_Typ := Class_Wide_Type (Etype (Act_Constr));
+ -- Check that the accessibility level of the tag is no deeper than that
+ -- of the constructor function.
+
+ Insert_Action (N,
+ Make_Implicit_If_Statement (N,
+ Condition =>
+ Make_Op_Gt (Loc,
+ Left_Opnd =>
+ Build_Get_Access_Level (Loc, New_Copy_Tree (Tag_Arg)),
+ Right_Opnd =>
+ Make_Integer_Literal (Loc, Scope_Depth (Act_Constr))),
+
+ Then_Statements => New_List (
+ Make_Raise_Statement (Loc,
+ New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
+
if Is_Interface (Etype (Act_Constr)) then
-- If the result type is not known to be a parent of Tag_Arg then we
@@ -390,7 +431,6 @@ package body Exp_Intr is
-- conversion of the call to the actual constructor.
Rewrite (N, Convert_To (Result_Typ, Cnstr_Call));
- Analyze_And_Resolve (N, Etype (Act_Constr));
-- Do not generate a run-time check on the built object if tag
-- checks are suppressed for the result type or tagged type expansion
@@ -458,6 +498,8 @@ package body Exp_Intr is
Make_Raise_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
end if;
+
+ Analyze_And_Resolve (N, Etype (Act_Constr));
end Expand_Dispatching_Constructor_Call;
---------------------------