diff mbox

[Ada] Avoid reporting redundant message on inherited subprogram

Message ID 20110902082612.GA5519@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Sept. 2, 2011, 8:26 a.m. UTC
This patch avoids reporting a redundant error on primitives inherited
from primitives.

  package Test_Pkg is
      type I1 is Interface;
      procedure P (A : I1) is abstract;

      type I2 is interface;
      procedure Q (B : I2) is abstract;

      type DT2 is new I1 and I2 with null record;
      procedure P (X : DT2);
   end;

Command: gcc -c -gnat05 test_pkg.ads
New output:
test_pkg.ads:8:12: type must be declared abstract or "Q" overridden
test_pkg.ads:8:12: "Q" has been inherited from subprogram at line 6

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-02  Javier Miranda  <miranda@adacore.com>

	* sem_ch3.adb (Check_Abstract_Overriding): When
	traversing the chain of aliased subprograms avoid reporting a
	redundant error on the current entity.
diff mbox

Patch

Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 178438)
+++ sem_ch3.adb	(working copy)
@@ -9105,9 +9105,16 @@ 
                         begin
                            E := Subp;
                            while Present (Alias (E)) loop
-                              Error_Msg_Sloc := Sloc (E);
-                              Error_Msg_NE
-                                ("\& has been inherited #", T, Subp);
+
+                              --  Avoid reporting redundant errors on entities
+                              --  inherited from interfaces
+
+                              if Sloc (E) /= Sloc (T) then
+                                 Error_Msg_Sloc := Sloc (E);
+                                 Error_Msg_NE
+                                   ("\& has been inherited #", T, Subp);
+                              end if;
+
                               E := Alias (E);
                            end loop;