gcc reports two different error messages, the second of them doesn't
seem to be correct. If it is somehow correct (I don't think so),
it is still misleading:

$ gnatmake -gnatv p.adb
gcc -c -gnatv p.adb

GNAT 4.3.0 20070127 (experimental)
Copyright 1992-2006, Free Software Foundation, Inc.

Compiling: p.adb (source file time stamp: 2007-01-27 13:38:37)

     5.         this.x := value;
                |
        >>> left hand side of assignment must be a variable

    10.         this.x := 42;
                |
        >>> assignment to "in" mode parameter not allowed

 13 lines: 2 errors
gnatmake: "p.adb" compilation error

The first message is correct because "this" is a pointer to constant.
The second message should be the same because the parameter mode should
only affects the mode of the pointer parameter ("this") not the pointee.
(When T_Ptr is made access-to-variable, both lines compile fine.)

package P is

    type T is tagged limited private;
    type T_Ptr is access constant T; -- Note: constant

    procedure reset(this: T_Ptr);
    procedure set(this: T_Ptr; value: Integer);

private

    type T is tagged limited record
        x: Integer;
    end record;

end P;

package body P is

    procedure set(this: T_Ptr; value: Integer) is
    begin
        this.x := value;
    end set;

    procedure reset(this: T_Ptr) is
    begin
        this.x := 42;
    end reset;

end P;


-- 
           Summary: compiler puts the blame on in parameter mode, not
                    pointer to constant, for assignment to component
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bauhaus at futureapps dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30614

Reply via email to