aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-02-06 11:00:38 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2013-02-06 11:00:38 +0100
commit1aee1fb38d2776cb3fb336138e77da61aef8aab1 (patch)
treebba29117d6ac951a5fef1335f9a8704e416b7bc8 /gcc/ada/sem_util.adb
parent2ae395d6c2478de339b17ffffdb83144e6518ea9 (diff)
downloadgcc-1aee1fb38d2776cb3fb336138e77da61aef8aab1.zip
gcc-1aee1fb38d2776cb3fb336138e77da61aef8aab1.tar.gz
gcc-1aee1fb38d2776cb3fb336138e77da61aef8aab1.tar.bz2
[multiple changes]
2013-02-06 Gary Dismukes <dismukes@adacore.com> * sem_ch6.adb (Check_For_Primitive_Subprogram): Test for the special case of a user-defined equality that overrides the predefined equality of a nonderived type declared in a declarative part. * sem_util.adb (Collect_Primitive_Operations): Add test for Is_Primitive when looping over the subprograms following a type, to catch the case of primitives such as a user-defined equality, which otherwise won't be found when the type is not a derived type and is declared in a declarative part. 2013-02-06 Vincent Celier <celier@adacore.com> * prj-conf.adb (Check_Target): Always return True when Target is empty (Get_Or_Create_Configuration_File.Get_Project_Target): New procedure to get the value of attribute Target in the main project. (Get_Or_Create_Configuration_File.Do_Autoconf): No need to get the value of attribute Target in the main project. (Get_Or_Create_Configuration_File): Call Get_Project_Target and use the target fom this call. 2013-02-06 Eric Botcazou <ebotcazou@adacore.com> * erroutc.adb (Validate_Specific_Warning): Do not issue the warning about an ineffective Pragma Warnings for -Wxxx warnings. * sem_prag.adb (Analyze_Pragma) <Warnings>: Accept -Wxxx warnings. * gnat_rm.texi (Pragma Warnings): Document coordination with warnings of the GCC back-end. From-SVN: r195786
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r--gcc/ada/sem_util.adb39
1 files changed, 27 insertions, 12 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 336ce67..aa58560 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -2577,6 +2577,7 @@ package body Sem_Util is
Op_List : Elist_Id;
Formal : Entity_Id;
Is_Prim : Boolean;
+ Is_Type_In_Pkg : Boolean;
Formal_Derived : Boolean := False;
Id : Entity_Id;
@@ -2636,12 +2637,9 @@ package body Sem_Util is
null;
end if;
- elsif (Is_Package_Or_Generic_Package (B_Scope)
- and then
- Nkind (Parent (Declaration_Node (First_Subtype (T)))) /=
- N_Package_Body)
- or else Is_Derived_Type (B_Type)
- then
+ -- Locate the primitive subprograms of the type
+
+ else
-- The primitive operations appear after the base type, except
-- if the derivation happens within the private part of B_Scope
-- and the type is a private type, in which case both the type
@@ -2657,13 +2655,30 @@ package body Sem_Util is
Id := Next_Entity (B_Type);
end if;
+ -- Set flag if this is a type in a package spec
+
+ Is_Type_In_Pkg :=
+ Is_Package_Or_Generic_Package (B_Scope)
+ and then
+ Nkind (Parent (Declaration_Node (First_Subtype (T)))) /=
+ N_Package_Body;
+
while Present (Id) loop
- -- Note that generic formal subprograms are not
- -- considered to be primitive operations and thus
- -- are never inherited.
+ -- Test whether the result type or any of the parameter types of
+ -- each subprogram following the type match that type when the
+ -- type is declared in a package spec, is a derived type, or the
+ -- subprogram is marked as primitive. (The Is_Primitive test is
+ -- needed to find primitives of nonderived types in declarative
+ -- parts that happen to override the predefined "=" operator.)
+
+ -- Note that generic formal subprograms are not considered to be
+ -- primitive operations and thus are never inherited.
if Is_Overloadable (Id)
+ and then (Is_Type_In_Pkg
+ or else Is_Derived_Type (B_Type)
+ or else Is_Primitive (Id))
and then Nkind (Parent (Parent (Id)))
not in N_Formal_Subprogram_Declaration
then
@@ -2684,9 +2699,9 @@ package body Sem_Util is
end loop;
end if;
- -- For a formal derived type, the only primitives are the
- -- ones inherited from the parent type. Operations appearing
- -- in the package declaration are not primitive for it.
+ -- For a formal derived type, the only primitives are the ones
+ -- inherited from the parent type. Operations appearing in the
+ -- package declaration are not primitive for it.
if Is_Prim
and then (not Formal_Derived