Commit 6ab24ed7 by Ed Schonberg Committed by Pierre-Marie de Rodat

[Ada] Improper error message on equality op with different operand types

2019-08-12  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch6.adb (heck_Untagged_Equality): Verify that user-defined
	equality has the same profile as the predefined equality before
	applying legality rule in RM 4.5.2 (9.8).

gcc/testsuite/

	* gnat.dg/equal10.adb, gnat.dg/equal10.ads: New testcase.

From-SVN: r274297
parent 2d56744e
2019-08-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (heck_Untagged_Equality): Verify that user-defined
equality has the same profile as the predefined equality before
applying legality rule in RM 4.5.2 (9.8).
2019-08-12 Bob Duff <duff@adacore.com> 2019-08-12 Bob Duff <duff@adacore.com>
* libgnat/a-except.ads: Update obsolete comment, still making * libgnat/a-except.ads: Update obsolete comment, still making
......
...@@ -8420,11 +8420,12 @@ package body Sem_Ch6 is ...@@ -8420,11 +8420,12 @@ package body Sem_Ch6 is
begin begin
-- This check applies only if we have a subprogram declaration with an -- This check applies only if we have a subprogram declaration with an
-- untagged record type. -- untagged record type that is conformant to the predefined op.
if Nkind (Decl) /= N_Subprogram_Declaration if Nkind (Decl) /= N_Subprogram_Declaration
or else not Is_Record_Type (Typ) or else not Is_Record_Type (Typ)
or else Is_Tagged_Type (Typ) or else Is_Tagged_Type (Typ)
or else Etype (Next_Formal (First_Formal (Eq_Op))) /= Typ
then then
return; return;
end if; end if;
......
2019-08-12 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/equal10.adb, gnat.dg/equal10.ads: New testcase.
2019-08-12 Gary Dismukes <dismukes@adacore.com> 2019-08-12 Gary Dismukes <dismukes@adacore.com>
* gnat.dg/suppress_initialization2.adb, * gnat.dg/suppress_initialization2.adb,
......
-- { dg-do compile }
package body Equal10 is
procedure Dummy is null;
end Equal10;
package Equal10 is
type R is record X : Integer; end record;
Rr : R;
function "=" (Y : R; Z : Integer) return Boolean is
(Y.X = Z);
procedure Dummy;
end Equal10;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment