comp.lang.ada
 help / color / mirror / Atom feed
* Which compiler is correct?
@ 1997-06-17  0:00 Tom Moran
  1997-06-18  0:00 ` Robert A Duff
  1997-06-18  0:00 ` Pascal Obry
  0 siblings, 2 replies; 26+ messages in thread
From: Tom Moran @ 1997-06-17  0:00 UTC (permalink / raw)



Compilers G and J accept this code.  Compiler O gives the error message
indicted in the comment, on said line.  Which is correct Ada?
package a is
    type x is tagged private;
private
    type x is tagged record
        i:integer;
    end record;
end a;
package a.b is
    type y is new x with private;
private
    type y is new x with record 
        j:integer;
    end record;
end a.b;
with a.b;
package a.c is
    type z is new a.b.y with private;
    procedure p;
private
    type z is new a.b.y with record
        k:integer;
    end record;
end a.c;
package body a.c is
    procedure p is
       one:x;
       two:z;
    begin
        one.i:=1;
        two.k:=2;
        two.i:=3;   -- test_vis.ada: Error: line 31 col 13 LRM:4.1.3(5),
No possible interpretation for selected component i, Ignoring future
references 

    end p;
end a.c;




^ permalink raw reply	[flat|nested] 26+ messages in thread
* Which compiler is correct??
@ 1996-09-10  0:00 Robert B. Love 
  1996-09-10  0:00 ` Robert Dewar
                   ` (4 more replies)
  0 siblings, 5 replies; 26+ messages in thread
From: Robert B. Love  @ 1996-09-10  0:00 UTC (permalink / raw)




I've got a situation where I put the same piece of code thru two
compilers on the same hardware and one will compile it, the other
gives errors.  The code is listed below and is taken from Richard
Riehle's article in JOOP on "Managing Runtime Faults".  GNAT compiles
it fine.  Aacademic ObjectAda fails to compile it.

I can see maybe 4 choices:  1)  GNAT is wrong, 2) ObjectAda is
wrong, 3) the code is wrong, 4) I need to set some compile
switches on one compiler or the other.

On a PC with GNAT 304a touted as being compiled for Windows and
GNAT 301 on a NeXT/M68040 I get no errors.

With Academic ObjectAda v7.0.171 I get 3 occurrences of the same error
along with line and column numbers.
  
      LRM:6.4.15(5) If the mode is IN OUT or OUT, the actual
      shall be a name that denotes a variable.

I need a language lawyer to tell me what is actually wrong.

Note I made 2 change to Riehle's article, commented with "my change"


with ada.exceptions; use ada.exceptions;
with text_io,ada.integer_text_io;use text_io;

procedure exception_demo is
   error_list: array(1..3) of exception_occurrence;
   d1,d2,d3: integer;

   function square(data:integer) return integer is
   begin
      return data*data;
   exception
      when error_in_square_function:
        constraint_error => ada.exceptions.save_occurrence
          (error_in_square_function,error_list(1));
        return 0;
   end square;

   function compute(v1,v2:integer) return integer is
   begin
      return square(v1) + square(v2);
   exception
      when error_in_compute:
        constraint_error=>ada.exceptions.save_occurrence
          (error_in_compute,error_list(2));
        return 0; -- my change
   end compute;

begin
   Ada.Integer_Text_Io.Get(Item=>D1);
   Ada.Integer_Text_Io.Get(Item=>D2);
   D3 := Compute(V1=>D1,V2=>D2);  -- my chanage
exception
   when Error_In_Demo:
     others => Ada.Exceptions.Save_Occurrence
       (Error_In_Demo,Error_List(3));
     for I in Error_List'Range loop
        Text_Io.Put_Line(Exception_Message(Error_List(I)));
        Text_Io.Put_Line(Exception_Name(Error_List(I)));
        Text_Io.Put_Line(Exception_Information(Error_List(I)));
     end loop;
end exception_demo;



----------------------------------------------------------------
Bob Love, rlove@neosoft.com (local)        MIME & NeXT Mail OK
rlove@raptor.rmnug.org  (permanent)        PGP key available
----------------------------------------------------------------





^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~1997-06-26  0:00 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-17  0:00 Which compiler is correct? Tom Moran
1997-06-18  0:00 ` Robert A Duff
1997-06-18  0:00   ` John Woodruff
1997-06-19  0:00     ` Robert A Duff
1997-06-20  0:00     ` Jon S Anthony
1997-06-21  0:00       ` Robert A Duff
1997-06-26  0:00         ` Jon S Anthony
1997-06-19  0:00   ` Simon Wright
1997-06-20  0:00     ` Jon S Anthony
1997-06-21  0:00       ` Robert A Duff
1997-06-21  0:00     ` Robert A Duff
1997-06-21  0:00       ` Simon Wright
1997-06-23  0:00       ` Mats.Weber
1997-06-24  0:00         ` Jon S Anthony
1997-06-18  0:00 ` Pascal Obry
1997-06-18  0:00   ` Tom Moran
  -- strict thread matches above, loose matches on Subject: below --
1996-09-10  0:00 Which compiler is correct?? Robert B. Love 
1996-09-10  0:00 ` Robert Dewar
1996-09-11  0:00   ` Robert B. Love 
1996-09-10  0:00 ` Robert Dewar
1996-09-11  0:00 ` Robert A Duff
1996-09-12  0:00   ` Ken Cowan
1996-09-12  0:00   ` Ken Cowan
1996-09-13  0:00   ` Jon S Anthony
1996-09-11  0:00 ` Jon S Anthony
1996-09-12  0:00 ` Tucker Taft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox