diff mbox series

[Ada] Missing error in function expressions

Message ID 20170908133127.GA87369@adacore.com
State New
Headers show
Series [Ada] Missing error in function expressions | expand

Commit Message

Arnaud Charlet Sept. 8, 2017, 1:31 p.m. UTC
The compiler skips reporting errors located in function expressions.
After this patch the error is reported in the following sources:

package Base is
   type Base_Type is tagged record
      V : Integer;
   end record;

   function Func_1 (B : Base_Type) return Integer is (B.V);
end;

with Base;
package DB is
   type DB_Type is new Base.Base_Type with record
      Y : Integer;
   end record;

   overriding
   function Func_1 (B : DB_Type) return Integer;

private
   function Func_1 (B : DB_Type) return Integer is
     (Base.Func_1 (Base_Type (B)) / 8 * 4);     -- Error
end;

Command: gcc -c db.ads
Output:
  db.ads:13:20: "Base_Type" is not visible
  db.ads:13:20: non-visible declaration at base.ads:2

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

2017-09-08  Javier Miranda  <miranda@adacore.com>

	* sem_ch8.adb (Find_Direct_Name.Undefined): Do
	not add entries into the undefined reference table when we are
	compiling with errors ignored.
diff mbox series

Patch

Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb	(revision 251892)
+++ sem_ch8.adb	(working copy)
@@ -5328,9 +5328,10 @@ 
          --  Make entry in undefined references table unless the full errors
          --  switch is set, in which case by refraining from generating the
          --  table entry, we guarantee that we get an error message for every
-         --  undefined reference.
+         --  undefined reference. The entry is not added if we are ignoring
+         --  errors.
 
-         if not All_Errors_Mode then
+         if not All_Errors_Mode and then Ignore_Errors_Enable = 0 then
             Urefs.Append (
               (Node => N,
                Err  => Emsg,