https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83935

--- Comment #10 from Tom Tromey <tromey at gcc dot gnu.org> ---
I have been looking at this again recently, for Ada, and now
I think perhaps the approach that GCC takes should be preferred.

At first I was thinking maybe the compiler could linearize
the members of the emitted structure, but I tried modifying
the example in comment #2 to add multiple variants with different
discriminators:

package Pck is

   type Rec (I : Integer; J: Integer) is record
      case I is
         when Positive =>
            C : Character;
            case J is
               when 0 =>
                  null;
               when others =>
                  N : Natural;
            end case;
         when others =>
            S : String (1 .. 10);
      end case;
   end record;

   R : Rec (1, 2);

end Pck;


... this seems to work and I think means that nested variant parts
is indeed a sensible way to go.

Reply via email to