parse.adb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. -- Copyright 2009-2022 Free Software Foundation, Inc.
  2. --
  3. -- This program is free software; you can redistribute it and/or modify
  4. -- it under the terms of the GNU General Public License as published by
  5. -- the Free Software Foundation; either version 3 of the License, or
  6. -- (at your option) any later version.
  7. --
  8. -- This program is distributed in the hope that it will be useful,
  9. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. -- GNU General Public License for more details.
  12. --
  13. -- You should have received a copy of the GNU General Public License
  14. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. -- This program declares a bunch of unconstrained objects and
  16. -- discrinimated records; the goal is to check that GDB does not crash
  17. -- when printing them even if they are not initialized.
  18. with Parse_Controlled;
  19. procedure Parse is -- START
  20. A : aliased Integer := 1;
  21. type Access_Type is access all Integer;
  22. type String_Access is access String;
  23. type My_Record is record
  24. Field1 : Access_Type;
  25. Field2 : String (1 .. 2);
  26. end record;
  27. type Discriminants_Record (A : Integer; B : Boolean) is record
  28. C : Float;
  29. end record;
  30. Z : Discriminants_Record := (A => 1, B => False, C => 2.0);
  31. type Variable_Record (A : Boolean := True) is record
  32. case A is
  33. when True =>
  34. B : Integer;
  35. when False =>
  36. C : Float;
  37. D : Integer;
  38. end case;
  39. end record;
  40. Y : Variable_Record := (A => True, B => 1);
  41. Y2 : Variable_Record := (A => False, C => 1.0, D => 2);
  42. Nv : Parse_Controlled.Null_Variant;
  43. type Union_Type (A : Boolean := False) is record
  44. case A is
  45. when True => B : Integer;
  46. when False => C : Float;
  47. end case;
  48. end record;
  49. pragma Unchecked_Union (Union_Type);
  50. Ut : Union_Type := (A => True, B => 3);
  51. type Tagged_Type is tagged record
  52. A : Integer;
  53. B : Character;
  54. end record;
  55. Tt : Tagged_Type := (A => 2, B => 'C');
  56. type Child_Tagged_Type is new Tagged_Type with record
  57. C : Float;
  58. end record;
  59. Ctt : Child_Tagged_Type := (Tt with C => 4.5);
  60. type Child_Tagged_Type2 is new Tagged_Type with null record;
  61. Ctt2 : Child_Tagged_Type2 := (Tt with null record);
  62. type My_Record_Array is array (Natural range <>) of My_Record;
  63. W : My_Record_Array := ((Field1 => A'Access, Field2 => "ab"),
  64. (Field1 => A'Access, Field2 => "rt"));
  65. type Discriminant_Record (Num1, Num2,
  66. Num3, Num4 : Natural) is record
  67. Field1 : My_Record_Array (1 .. Num2);
  68. Field2 : My_Record_Array (Num1 .. 10);
  69. Field3 : My_Record_Array (Num1 .. Num2);
  70. Field4 : My_Record_Array (Num3 .. Num2);
  71. Field5 : My_Record_Array (Num4 .. Num2);
  72. end record;
  73. Dire : Discriminant_Record (1, 7, 3, 0);
  74. type Null_Variant_Part (Discr : Integer) is record
  75. case Discr is
  76. when 1 => Var_1 : Integer;
  77. when 2 => Var_2 : Boolean;
  78. when others => null;
  79. end case;
  80. end record;
  81. Nvp : Null_Variant_Part (3);
  82. type T_Type is array (Positive range <>) of Integer;
  83. type T_Ptr_Type is access T_Type;
  84. T_Ptr : T_Ptr_Type := new T_Type' (13, 17);
  85. T_Ptr2 : T_Ptr_Type := new T_Type' (2 => 13, 3 => 17);
  86. function Foos return String is
  87. begin
  88. return "string";
  89. end Foos;
  90. My_Str : String := Foos;
  91. type Value_Var_Type is ( V_Null, V_Boolean, V_Integer );
  92. type Value_Type( Var : Value_Var_Type := V_Null ) is
  93. record
  94. case Var is
  95. when V_Null =>
  96. null;
  97. when V_Boolean =>
  98. Boolean_Value : Boolean;
  99. when V_Integer =>
  100. Integer_Value : Integer;
  101. end case;
  102. end record;
  103. NBI_N : Value_Type := (Var => V_Null);
  104. NBI_I : Value_Type := (Var => V_Integer, Integer_Value => 18);
  105. NBI_B : Value_Type := (Var => V_Boolean, Boolean_Value => True);
  106. begin
  107. null;
  108. end Parse;