aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog172
-rw-r--r--gcc/ada/atree.adb2
-rw-r--r--gcc/ada/comperr.adb16
-rw-r--r--gcc/ada/doc/gnat_rm/gnat_language_extensions.rst156
-rw-r--r--gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst29
-rw-r--r--gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst59
-rw-r--r--gcc/ada/einfo-utils.adb9
-rw-r--r--gcc/ada/einfo.ads2
-rw-r--r--gcc/ada/exp_util.adb28
-rw-r--r--gcc/ada/gcc-interface/decl.cc20
-rw-r--r--gcc/ada/gnat_rm.texi267
-rw-r--r--gcc/ada/gnat_ugn.texi114
-rw-r--r--gcc/ada/gnatcmd.adb2
-rw-r--r--gcc/ada/libgnat/s-secsta.adb9
-rw-r--r--gcc/ada/libgnat/s-secsta__cheri.adb9
-rw-r--r--gcc/ada/libgnat/s-valuef.adb37
-rw-r--r--gcc/ada/libgnat/s-valuer.adb23
-rw-r--r--gcc/ada/opt.ads25
-rw-r--r--gcc/ada/repinfo.adb297
-rw-r--r--gcc/ada/sem_ch12.adb499
-rw-r--r--gcc/ada/sem_ch3.adb104
-rw-r--r--gcc/ada/sem_ch8.ads5
-rw-r--r--gcc/ada/sem_util.adb12
-rw-r--r--gcc/ada/sem_util.ads6
-rw-r--r--gcc/ada/sem_warn.adb14
-rw-r--r--gcc/ada/sinfo.ads2
-rw-r--r--gcc/ada/switch-c.adb21
-rw-r--r--gcc/ada/switch.adb2
-rw-r--r--gcc/ada/treepr.adb2
-rw-r--r--gcc/ada/usage.adb12
-rw-r--r--gcc/ada/vast.adb519
31 files changed, 1619 insertions, 855 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 102be17..f51e899 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,175 @@
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Generate
+ a zero-initialization for the anonymous object of a small aggregate
+ allocated on the stack.
+ (inline_status_for_subprog): Minor tweak.
+
+2025-06-12 Tonu Naks <naks@adacore.com>
+
+ * comperr.adb: update support instructions
+ * switch.adb: update support instructions
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sinfo.ads: Fix RM reference.
+
+2025-06-12 Piotr Trojanek <trojanek@adacore.com>
+
+ * sem_ch3.adb (Apply_External_Initialization): Reuse local constant.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * doc/gnat_rm/gnat_language_extensions.rst
+ (Generalized Finalization): Document the actual implementation.
+ (No_Raise): Move to separate section.
+ * gnat_rm.texi: Regenerate.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * libgnat/s-valuer.adb (Scan_Raw_Real): Apply tweak.
+
+2025-06-12 Tonu Naks <naks@adacore.com>
+
+ * comperr.adb: replace report@ with support@
+ * gnatcmd.adb: replace report@ with support@
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_ch3.adb (Build_Derived_Private_Type): Fix test.
+ (Build_Derived_Record_Type): Adjust error recovery paths.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * einfo.ads (Has_Homonym): Fix inaccuracy in description.
+ * sem_ch8.ads (Find_Direct_Name): Remove obsolete description.
+ * sem_ch12.adb (Analyze_Associations): Rename I_Node parameter
+ into N and adjust description.
+ (Analyze_Subprogram_Instantiation): Add missing description.
+ (Contains_Instance_Of): Fix description.
+ (Associations): Rename Generic_Actual_Rec into Actual_Rec and
+ Gen_Assocs_Rec into Match_Rec.
+ (Analyze_One_Association): Rename I_Node parameter into N.
+ (Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into
+ Match.
+ (Body of Associations): Minor cleanups and tweaks.
+ (Analyze_Associations): Rename I_Node parameter into N and
+ adjust implementation.
+ (Analyze_One_Association): Likewise.
+ (Analyze_Package_Instantiation): Remove obsolete code and clean up.
+ (Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into
+ Match and adjust implementation.
+ (Freeze_Package_Instance): Simplify condition.
+ (Get_Unit_Instantiation_Node): Add support for instantiations of
+ subprograms and stop the loop properly in case of errors.
+ * sem_util.ads (Add_Global_Declaration): Rename N parameter into
+ Decl and fix description.
+ * sem_util.adb (Add_Global_Declaration): Rename N parameter into
+ Decl and adjust implementation.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * libgnat/s-valuer.adb (Scan_Raw_Real): Add RM reference.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * libgnat/s-valuer.adb (Scan_Raw_Real): Remove subexpression. Improve
+ surrounding comments.
+
+2025-06-12 Bob Duff <duff@adacore.com>
+
+ * vast.adb: Check basic tree properties.
+ * atree.adb (Traverse_Field): Minor.
+ * treepr.adb (Destroy): Minor comment.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * libgnat/s-valuer.adb (Round_Extra): Use multiplicative test.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * einfo-utils.adb (Set_Convention): Remove obsolete test.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_ch3.adb (Process_Discriminants): Set Ekind earlier.
+ * sem_util.adb (Enter_Name): Adjust error processing.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * libgnat/s-valuef.adb (Integer_To_Fixed): Enable overflow checks.
+ Deal specifically with Val = 2**(Int'Size - 1) if Minus is not set.
+ Exit the loop when V saturates to 0 in the case of (huge) negative
+ exponents.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * exp_util.adb (Insert_Actions): Refine test.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
+ switches) <-O>: Fix long line.
+ * gnat_ugn.texi: Regenerate.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (List of
+ all switches): Add -gnatRh subswitch.
+ (Debugging Control): Document -gnatRh subswitch.
+ * opt.ads (List_Representation_Info_Holes): New boolean variable.
+ * repinfo.adb: Add with clause for GNAT.Heap_Sort_G.
+ (List_Common_Type_Info): Relax assertion.
+ (List_Object_Info): Replace assertion with additional test.
+ (List_Record_Layout): If -gnatRh is specified, make sure that the
+ components are ordered by increasing offsets. Output a comment
+ line giving the number of unused bits if there is a hole between
+ consecutive components. Streamline the control flow of the loop.
+ (List_Record_Info): Use the original record type giving the layout
+ of components, if any, to display the layout of the record.
+ * switch-c.adb (Scan_Front_End_Switches) <-gnatR>: Add support for
+ -gnatRh subswitch.
+ * usage.adb (Usage): Document -gnatRh subswitch.
+ * gnat_ugn.texi: Regenerate.
+
+2025-06-12 Johannes Kliemann <kliemann@adacore.com>
+
+ * libgnat/s-secsta.adb (SS_Allocate): Add comment about
+ conservative alignment padding calculation.
+ * libgnat/s-secsta__cheri.adb (SS_Allocate): Add comment about
+ conservative alignment padding calculation.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_warn.adb (Check_References): Rewrite expression
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_ch3.adb (Constrain_Index, Make_Index, Array_Type_Declaration,
+ Analyze_Number_Declaration): Remove uses of E_Void.
+
+2025-06-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * usage.adb (Usage): Justify the documentation of common switches
+ like that of other switches. Rework that of the -O switch.
+ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
+ switches) <-O>: Rework and document 'z' and 'g' operands.
+ * doc/gnat_ugn/gnat_and_program_execution.rst (Optimization Levels):
+ Rework and document -Oz and -Og switches.
+ * gnat_ugn.texi: Regenerate.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_ch3.adb (Constrain_Index): Avoid unused itypes.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_ch3.adb (Constrain_Index): Factorize return statement.
+
+2025-06-12 Ronan Desplanques <desplanques@adacore.com>
+
+ * sem_ch3.adb (Build_Derived_Numeric_Type): Remove duplicate call.
+
2025-06-10 Piotr Trojanek <trojanek@adacore.com>
* gen_il-gen-gen_entities.adb (Formal_Object_Kind): Remove
diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb
index 3fa55a7..17538de 100644
--- a/gcc/ada/atree.adb
+++ b/gcc/ada/atree.adb
@@ -2702,9 +2702,9 @@ package body Atree is
-- tail recursive step won't go past the end.
declare
- Cur_Field : Offset_Array_Index := Traversed_Offset_Array'First;
Offsets : Traversed_Offset_Array renames
Traversed_Fields (Nkind (Cur_Node));
+ Cur_Field : Offset_Array_Index := Traversed_Offset_Array'First;
begin
if Offsets (Traversed_Offset_Array'First) /= No_Field_Offset then
diff --git a/gcc/ada/comperr.adb b/gcc/ada/comperr.adb
index 180ea94..602b13d 100644
--- a/gcc/ada/comperr.adb
+++ b/gcc/ada/comperr.adb
@@ -307,16 +307,16 @@ package body Comperr is
Write_Str
("| Please submit a bug report by email " &
- "to report@adacore.com.");
+ "to support@adacore.com.");
End_Line;
Write_Str
- ("| GAP members can alternatively use GNAT Tracker:");
+ ("| GAP members can alternatively use GNATtracker:");
End_Line;
Write_Str
- ("| https://www.adacore.com/login?mode=gap " &
- "section 'Create New Ticket'.");
+ ("| https://support.adacore.com/csm " &
+ "by using the button 'Create A New Case'.");
End_Line;
Write_Str
@@ -326,17 +326,17 @@ package body Comperr is
else
Write_Str
- ("| Please submit a bug report using GNAT Tracker:");
+ ("| Please submit a bug report using GNATtracker at");
End_Line;
Write_Str
- ("| https://www.adacore.com/login " &
- "section 'Create New Ticket'.");
+ ("| https://support.adacore.com/csm " &
+ "by using the button 'Create New Case'.");
End_Line;
Write_Str
("| Or submit a bug report by email " &
- "to report@adacore.com");
+ "to support@adacore.com");
End_Line;
Write_Str
diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
index 1713f56..0a08a83 100644
--- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
+++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
@@ -1469,97 +1469,60 @@ that the record type must be a root type, in other words not a derived type.
The aspect additionally makes it possible to specify relaxed semantics for
the finalization operations by means of the ``Relaxed_Finalization`` setting.
-
-Example:
+Here is the archetypal example:
.. code-block:: ada
- type Ctrl is record
- Id : Natural := 0;
+ type T is record
+ ...
end record
with Finalizable => (Initialize => Initialize,
Adjust => Adjust,
Finalize => Finalize,
Relaxed_Finalization => True);
- procedure Adjust (Obj : in out Ctrl);
- procedure Finalize (Obj : in out Ctrl);
- procedure Initialize (Obj : in out Ctrl);
-
-The three procedures have the same profile, taking a single ``in out T``
-parameter.
+ procedure Adjust (Obj : in out T);
+ procedure Finalize (Obj : in out T);
+ procedure Initialize (Obj : in out T);
-We follow the same dynamic semantics as controlled objects:
+The three procedures have the same profile, with a single ``in out`` parameter,
+and also have the same dynamic semantics as for controlled types:
- ``Initialize`` is called when an object of type ``T`` is declared without
- default expression.
+ initialization expression.
- ``Adjust`` is called after an object of type ``T`` is assigned a new value.
- ``Finalize`` is called when an object of type ``T`` goes out of scope (for
- stack-allocated objects) or is explicitly deallocated (for heap-allocated
- objects). It is also called when on the value being replaced in an
- assignment.
-
-However the following differences are enforced by default when compared to the
-current Ada controlled-objects finalization model:
-
-* No automatic finalization of heap allocated objects: ``Finalize`` is only
- called when an object is implicitly deallocated. As a consequence, no-runtime
- support is needed for the implicit case, and no header will be maintained for
- this in heap-allocated controlled objects.
-
- Heap-allocated objects allocated through a nested access type definition will
- hence **not** be deallocated either. The result is simply that memory will be
- leaked in those cases.
-
-* The ``Finalize`` procedure should have have the :ref:`No_Raise_Aspect` specified.
- If that's not the case, a compilation error will be raised.
-
-Additionally, two other configuration aspects are added,
-``Legacy_Heap_Finalization`` and ``Exceptions_In_Finalize``:
-
-* ``Legacy_Heap_Finalization``: Uses the legacy automatic finalization of
- heap-allocated objects
-
-* ``Exceptions_In_Finalize``: Allow users to have a finalizer that raises exceptions
- **NB!** note that using this aspect introduces execution time penalities.
-
-.. _No_Raise_Aspect:
-
-No_Raise aspect
-----------------
+ stack-allocated objects) or is deallocated (for heap-allocated objects).
+ It is also called when the value is replaced by an assignment.
-The ``No_Raise`` aspect can be applied to a subprogram to declare that this subprogram is not
-expected to raise any exceptions. Should an exception still occur during the execution of
-this subprogram, ``Program_Error`` is raised.
+However, when ``Relaxed_Finalization`` is either ``True`` or not explicitly
+specified, the following differences are implemented relative to the semantics
+of controlled types:
-New specification for ``Ada.Finalization.Controlled``
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+* The compiler has permission to perform no automatic finalization of
+ heap-allocated objects: ``Finalize`` is only called when such an object
+ is explicitly deallocated, or when the designated object is assigned a new
+ value. As a consequence, no runtime support is needed for performing
+ implicit deallocation. In particular, no per-object header data is needed
+ for heap-allocated objects.
-``Ada.Finalization.Controlled`` is now specified as:
-
-.. code-block:: ada
-
- type Controlled is abstract tagged null record
- with Initialize => Initialize,
- Adjust => Adjust,
- Finalize => Finalize,
- Legacy_Heap_Finalization, Exceptions_In_Finalize;
-
- procedure Initialize (Self : in out Controlled) is abstract;
- procedure Adjust (Self : in out Controlled) is abstract;
- procedure Finalize (Self : in out Controlled) is abstract;
+ Heap-allocated objects allocated through a nested access type will therefore
+ **not** be deallocated either. The result is simply that memory will be leaked
+ in this case.
+* The ``Adjust`` and ``Finalize`` procedures are automatically considered as
+ having the :ref:`No_Raise_Aspect` specified for them. In particular, the
+ compiler has permission to enforce none of the guarantees specified by the
+ RM 7.6.1 (14/1) and subsequent subclauses.
-### Examples
-
-A simple example of a ref-counted type:
+Simple example of ref-counted type:
.. code-block:: ada
type T is record
- Value : Integer;
+ Value : Integer;
Ref_Count : Natural := 0;
end record;
@@ -1571,8 +1534,8 @@ A simple example of a ref-counted type:
type T_Ref is record
Value : T_Access;
end record
- with Adjust => Adjust,
- Finalize => Finalize;
+ with Finalizable => (Adjust => Adjust,
+ Finalize => Finalize);
procedure Adjust (Ref : in out T_Ref) is
begin
@@ -1584,8 +1547,7 @@ A simple example of a ref-counted type:
Def_Ref (Ref.Value);
end Finalize;
-
-A simple file handle that ensures resources are properly released:
+Simple file handle that ensures resources are properly released:
.. code-block:: ada
@@ -1595,51 +1557,47 @@ A simple file handle that ensures resources are properly released:
function Open (Path : String) return File;
procedure Close (F : in out File);
+
private
type File is limited record
Handle : ...;
end record
- with Finalize => Close;
-
-
-Finalized tagged types
-^^^^^^^^^^^^^^^^^^^^^^^
+ with Finalizable (Finalize => Close);
+ end P;
-Aspects are inherited by derived types and optionally overriden by those. The
-compiler-generated calls to the user-defined operations are then
-dispatching whenever it makes sense, i.e. the object in question is of
-class-wide type and the class includes at least one finalized tagged type.
+Finalizable tagged types
+^^^^^^^^^^^^^^^^^^^^^^^^
-However note that for simplicity, it is forbidden to change the value of any of
-those new aspects in derived types.
+The aspect is inherited by derived types and the primitives may be overridden
+by the derivation. The compiler-generated calls to these operations are then
+dispatching whenever it makes sense, i.e. when the object in question is of a
+class-wide type and the class includes at least one finalizable tagged type.
Composite types
^^^^^^^^^^^^^^^
-When a finalized type is used as a component of a composite type, the latter
-becomes finalized as well. The three primitives are derived automatically
-in order to call the primitives of their components.
-
-If that composite type was already user-finalized, then the compiler
-calls the primitives of the components so as to stay consistent with today's
-controlled types's behavior.
-
-So, ``Initialize`` and ``Adjust`` are called on components before they
-are called on the composite object, but ``Finalize`` is called on the composite
-object first.
+When a finalizable type is used as a component of a composite type, the latter
+becomes finalizable as well. The three primitives are derived automatically
+in order to call the primitives of their components. The dynamic semantics is
+the same as for controlled components of composite types.
Interoperability with controlled types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-As a consequence of the redefinition of the ``Controlled`` type as a base type
-with the new aspects defined, interoperability with controlled type naturally
-follows the definition of the above rules. In particular:
+Finalizable types are fully interoperable with controlled types, in particular
+it is possible for a finalizable type to have a controlled component and vice
+versa, but the stricter dynamic semantics, in other words that of controlled
+types, is applied in this case.
-* It is possible to have a new finalized type have a controlled type
- component
-* It is possible to have a controlled type have a finalized type
- component
+.. _No_Raise_Aspect:
+
+No_Raise aspect
+----------------
+The ``No_Raise`` aspect can be applied to a subprogram to declare that this
+subprogram is not expected to raise an exception. Should an exception still
+be raised during the execution of the subprogram, it is caught at the end of
+this execution and ``Program_Error`` is propagated to the caller.
Inference of Dependent Types in Generic Instantiations
------------------------------------------------------
diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
index 4f46fba..b99eba7 100644
--- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
+++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
@@ -2112,7 +2112,7 @@ Alphabetical List of All Switches
.. index:: -gnatR (gcc)
-:switch:`-gnatR[0|1|2|3|4][e][j][m][s]`
+:switch:`-gnatR[0|1|2|3|4][e][h][m][j][s]`
Output representation information for declared types, objects and
subprograms. Note that this switch is not allowed if a previous
:switch:`-gnatD` switch has been given, since these two switches
@@ -2259,15 +2259,16 @@ Alphabetical List of All Switches
======= ==================================================================
*n* Effect
------- ------------------------------------------------------------------
- *0* No optimization, the default setting if no :switch:`-O` appears
- *1* Normal optimization, the default if you specify :switch:`-O` without an
- operand. A good compromise between code quality and compilation
- time.
- *2* Extensive optimization, may improve execution time, possibly at
+ *0* No optimization, the default setting if no :switch:`-O` appears.
+ *1* Moderate optimization, same as :switch:`-O` without an operand.
+ A good compromise between code quality and compilation time.
+ *2* Extensive optimization, should improve execution time, possibly at
the cost of substantially increased compilation time.
- *3* Same as :switch:`-O2`, and also includes inline expansion for small
- subprograms in the same unit.
- *s* Optimize space usage
+ *3* Full optimization, may further improve execution time, possibly at
+ the cost of substantially larger generated code.
+ *s* Optimize for size (code and data) rather than speed.
+ *z* Optimize aggressively for size (code and data) rather than speed.
+ *g* Optimize for debugging experience rather than speed.
======= ==================================================================
See also :ref:`Optimization_Levels`.
@@ -6088,7 +6089,7 @@ Debugging Control
.. index:: -gnatR (gcc)
-:switch:`-gnatR[0|1|2|3|4][e][j][m][s]`
+:switch:`-gnatR[0|1|2|3|4][e][h][m][j][s]`
This switch controls output from the compiler of a listing showing
representation information for declared types, objects and subprograms.
For :switch:`-gnatR0`, no information is output (equivalent to omitting
@@ -6116,17 +6117,21 @@ Debugging Control
extended representation information for record sub-components of records
is included.
+ If the switch is followed by a ``h`` (e.g. :switch:`-gnatR3h`), then
+ the components of records are sorted by increasing offsets and holes
+ between consecutive components are flagged.
+
If the switch is followed by an ``m`` (e.g. :switch:`-gnatRm`), then
subprogram conventions and parameter passing mechanisms for all the
subprograms are included.
- If the switch is followed by a ``j`` (e.g., :switch:`-gnatRj`), then
+ If the switch is followed by a ``j`` (e.g. :switch:`-gnatRj`), then
the output is in the JSON data interchange format specified by the
ECMA-404 standard. The semantic description of this JSON output is
available in the specification of the Repinfo unit present in the
compiler sources.
- If the switch is followed by an ``s`` (e.g., :switch:`-gnatR3s`), then
+ If the switch is followed by an ``s`` (e.g. :switch:`-gnatR3s`), then
the output is to a file with the name :file:`file.rep` where ``file`` is
the name of the corresponding source file, except if ``j`` is also
specified, in which case the file name is :file:`file.json`.
diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
index 756bc74..4ecb3cf 100644
--- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
+++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
@@ -1584,18 +1584,16 @@ Turning on optimization makes the compiler attempt to improve the
performance and/or code size at the expense of compilation time and
possibly the ability to debug the program.
-If you use multiple :switch:`-O` switches, with or without level
-numbers, the last such switch is the one that's used.
-
-You can use the
-:switch:`-O` switch (the permitted forms are :switch:`-O0`, :switch:`-O1`
-:switch:`-O2`, :switch:`-O3`, and :switch:`-Os`)
-to ``gcc`` to control the optimization level:
+You can pass the :switch:`-O` switch, with or without an operand
+(the permitted forms with an operand are :switch:`-O0`, :switch:`-O1`,
+:switch:`-O2`, :switch:`-O3`, :switch:`-Os`, :switch:`-Oz`, and
+:switch:`-Og`) to ``gcc`` to control the optimization level. If you
+pass multiple :switch:`-O` switches, with or without an operand,
+the last such switch is the one that's used:
* :switch:`-O0`
- No optimization (the default);
- generates unoptimized code but has
+ No optimization (the default); generates unoptimized code but has
the fastest compilation time. Debugging is easiest with this switch.
Note that many other compilers do substantial optimization even if
@@ -1606,32 +1604,45 @@ to ``gcc`` to control the optimization level:
mind when doing performance comparisons.
* :switch:`-O1`
- Moderate optimization; optimizes reasonably well but does not
- degrade compilation time significantly. You may not be able to see
- some variables in the debugger and changing the value of some
- variables in the debugger may not have the effect you desire.
+ Moderate optimization (same as :switch:`-O` without an operand);
+ optimizes reasonably well but does not degrade compilation time
+ significantly. You may not be able to see some variables in the
+ debugger, and changing the value of some variables in the debugger
+ may not have the effect you desire.
* :switch:`-O2`
- Full optimization;
- generates highly optimized code and has
- the slowest compilation time. You may see significant impacts on
+ Extensive optimization; generates highly optimized code but has
+ an increased compilation time. You may see significant impacts on
your ability to display and modify variables in the debugger.
* :switch:`-O3`
- Full optimization as in :switch:`-O2`;
- also uses more aggressive automatic inlining of subprograms within a unit
- (:ref:`Inlining_of_Subprograms`) and attempts to vectorize loops.
-
+ Full optimization; attempts more sophisticated transformations, in
+ particular on loops, possibly at the cost of larger generated code.
+ You may be hardly able to use the debugger at this optimization level.
* :switch:`-Os`
- Optimize space usage (code and data) of resulting program.
+ Optimize for size (code and data) of resulting binary rather than
+ speed; based on the :switch:`-O2` optimization level, but disables
+ some of its transformations that often increase code size, as well
+ as performs further optimizations designed to reduce code size.
+
+* :switch:`-Oz`
+ Optimize aggressively for size (code and data) of resulting binary
+ rather than speed; may increase the number of instructions executed
+ if these instructions require fewer bytes to be encoded.
+
+* :switch:`-Og`
+ Optimize for debugging experience rather than speed; based on the
+ :switch:`-O1` optimization level, but attempts to eliminate all the
+ negative effects of optimization on debugging.
+
Higher optimization levels perform more global transformations on the
program and apply more expensive analysis algorithms in order to generate
faster and more compact code. The price in compilation time, and the
-resulting improvement in execution time,
-both depend on the particular application and the hardware environment.
-You should experiment to find the best level for your application.
+resulting improvement in execution time, both depend on the particular
+application and the hardware environment. You should experiment to find
+the best level for your application.
Since the precise set of optimizations done at each level will vary from
release to release (and sometime from target to target), it is best to think
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index 15f5b99..91d273c 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -2639,14 +2639,7 @@ package body Einfo.Utils is
-- anonymous protected types, since protected types always have the
-- default convention.
- if Present (Etype (E))
- and then (Is_Object (E)
-
- -- Allow E_Void (happens for pragma Convention appearing
- -- in the middle of a record applying to a component)
-
- or else Ekind (E) = E_Void)
- then
+ if Present (Etype (E)) and then Is_Object (E) then
declare
Typ : constant Entity_Id := Etype (E);
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 495a193..d8958d6 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -1689,7 +1689,7 @@ package Einfo is
--
-- Has_Homonym
-- Defined in all entities. Set if an entity has a homonym in the same
--- scope. Used by the backend to generate unique names for all entities.
+-- scope. Used by Exp_Dbug to generate unique names for all entities.
-- Has_Implicit_Dereference
-- Defined in types and discriminants. Set if the type has an aspect
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 8ac1b90..45eb808 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -8228,19 +8228,31 @@ package body Exp_Util is
return;
end if;
- -- the expansion of Task and protected type declarations can
+ -- The expansion of task and protected type declarations can
-- create declarations for temporaries which, like other actions
- -- are inserted and analyzed before the current declaraation.
- -- However, the current scope is the synchronized type, and
- -- for unnesting it is critical that the proper scope for these
- -- generated entities be the enclosing one.
+ -- are inserted and analyzed before the current declaration.
+ -- However, in some cases, the current scope is the synchronized
+ -- type, and for unnesting it is critical that the proper scope
+ -- for these generated entities be the enclosing one.
when N_Task_Type_Declaration
| N_Protected_Type_Declaration =>
- Push_Scope (Scope (Current_Scope));
- Insert_List_Before_And_Analyze (P, Ins_Actions);
- Pop_Scope;
+ declare
+ Skip_Scope : constant Boolean :=
+ Ekind (Current_Scope) in Concurrent_Kind;
+ begin
+ if Skip_Scope then
+ Push_Scope (Scope (Current_Scope));
+ end if;
+
+ Insert_List_Before_And_Analyze (P, Ins_Actions);
+
+ if Skip_Scope then
+ Pop_Scope;
+ end if;
+ end;
+
return;
-- A special case, N_Raise_xxx_Error can act either as a statement
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 1694b4e..972607a 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -1228,6 +1228,24 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
gnu_expr = gnat_build_constructor (gnu_type, v);
}
+ /* If we are allocating the anonymous object of a small aggregate on
+ the stack, zero-initialize it so that the entire object is assigned
+ and the subsequent assignments need not preserve unknown bits, but
+ do it only when optimization is enabled for the sake of consistency
+ with the gimplifier which does the same for CONSTRUCTORs. */
+ else if (definition
+ && !imported_p
+ && !static_flag
+ && !gnu_expr
+ && TREE_CODE (gnu_type) == RECORD_TYPE
+ && TREE_CODE (gnu_object_size) == INTEGER_CST
+ && compare_tree_int (gnu_object_size, MAX_FIXED_MODE_SIZE) <= 0
+ && Present (Related_Expression (gnat_entity))
+ && Nkind (Original_Node (Related_Expression (gnat_entity)))
+ == N_Aggregate
+ && optimize)
+ gnu_expr = build_constructor (gnu_type, NULL);
+
/* Convert the expression to the type of the object if need be. */
if (gnu_expr && initial_value_needs_conversion (gnu_type, gnu_expr))
gnu_expr = convert (gnu_type, gnu_expr);
@@ -5251,7 +5269,7 @@ inline_status_for_subprog (Entity_Id subprog)
&& Is_Record_Type (Etype (First_Formal (subprog)))
&& (gnu_type = gnat_to_gnu_type (Etype (First_Formal (subprog))))
&& !TYPE_IS_BY_REFERENCE_P (gnu_type)
- && tree_fits_uhwi_p (TYPE_SIZE (gnu_type))
+ && TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST
&& compare_tree_int (TYPE_SIZE (gnu_type), MAX_FIXED_MODE_SIZE) <= 0)
return is_prescribed;
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index f44260b..0ae1a24 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -942,10 +942,9 @@ Simpler Accessibility Model
* Subprogram parameters::
* Function results::
-No_Raise aspect
+Generalized Finalization
-* New specification for Ada.Finalization.Controlled: New specification for Ada Finalization Controlled.
-* Finalized tagged types::
+* Finalizable tagged types::
* Composite types::
* Interoperability with controlled types::
@@ -30939,27 +30938,24 @@ that the record type must be a root type, in other words not a derived type.
The aspect additionally makes it possible to specify relaxed semantics for
the finalization operations by means of the @code{Relaxed_Finalization} setting.
-
-Example:
+Here is the archetypal example:
@example
-type Ctrl is record
- Id : Natural := 0;
+type T is record
+ ...
end record
with Finalizable => (Initialize => Initialize,
Adjust => Adjust,
Finalize => Finalize,
Relaxed_Finalization => True);
-procedure Adjust (Obj : in out Ctrl);
-procedure Finalize (Obj : in out Ctrl);
-procedure Initialize (Obj : in out Ctrl);
+procedure Adjust (Obj : in out T);
+procedure Finalize (Obj : in out T);
+procedure Initialize (Obj : in out T);
@end example
-The three procedures have the same profile, taking a single @code{in out T}
-parameter.
-
-We follow the same dynamic semantics as controlled objects:
+The three procedures have the same profile, with a single @code{in out} parameter,
+and also have the same dynamic semantics as for controlled types:
@quotation
@@ -30968,98 +30964,49 @@ We follow the same dynamic semantics as controlled objects:
@item
@code{Initialize} is called when an object of type @code{T} is declared without
-default expression.
+initialization expression.
@item
@code{Adjust} is called after an object of type @code{T} is assigned a new value.
@item
@code{Finalize} is called when an object of type @code{T} goes out of scope (for
-stack-allocated objects) or is explicitly deallocated (for heap-allocated
-objects). It is also called when on the value being replaced in an
-assignment.
+stack-allocated objects) or is deallocated (for heap-allocated objects).
+It is also called when the value is replaced by an assignment.
@end itemize
@end quotation
-However the following differences are enforced by default when compared to the
-current Ada controlled-objects finalization model:
+However, when @code{Relaxed_Finalization} is either @code{True} or not explicitly
+specified, the following differences are implemented relative to the semantics
+of controlled types:
@itemize *
@item
-No automatic finalization of heap allocated objects: @code{Finalize} is only
-called when an object is implicitly deallocated. As a consequence, no-runtime
-support is needed for the implicit case, and no header will be maintained for
-this in heap-allocated controlled objects.
+The compiler has permission to perform no automatic finalization of
+heap-allocated objects: @code{Finalize} is only called when such an object
+is explicitly deallocated, or when the designated object is assigned a new
+value. As a consequence, no runtime support is needed for performing
+implicit deallocation. In particular, no per-object header data is needed
+for heap-allocated objects.
-Heap-allocated objects allocated through a nested access type definition will
-hence `not' be deallocated either. The result is simply that memory will be
-leaked in those cases.
+Heap-allocated objects allocated through a nested access type will therefore
+`not' be deallocated either. The result is simply that memory will be leaked
+in this case.
@item
-The @code{Finalize} procedure should have have the @ref{466,,No_Raise aspect} specified.
-If that’s not the case, a compilation error will be raised.
+The @code{Adjust} and @code{Finalize} procedures are automatically considered as
+having the @ref{466,,No_Raise aspect} specified for them. In particular, the
+compiler has permission to enforce none of the guarantees specified by the
+RM 7.6.1 (14/1) and subsequent subclauses.
@end itemize
-Additionally, two other configuration aspects are added,
-@code{Legacy_Heap_Finalization} and @code{Exceptions_In_Finalize}:
-
-
-@itemize *
-
-@item
-@code{Legacy_Heap_Finalization}: Uses the legacy automatic finalization of
-heap-allocated objects
-
-@item
-@code{Exceptions_In_Finalize}: Allow users to have a finalizer that raises exceptions
-`NB!' note that using this aspect introduces execution time penalities.
-@end itemize
-
-@node No_Raise aspect,Inference of Dependent Types in Generic Instantiations,Generalized Finalization,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions id3}@anchor{467}@anchor{gnat_rm/gnat_language_extensions no-raise-aspect}@anchor{466}
-@subsection No_Raise aspect
-
-
-The @code{No_Raise} aspect can be applied to a subprogram to declare that this subprogram is not
-expected to raise any exceptions. Should an exception still occur during the execution of
-this subprogram, @code{Program_Error} is raised.
-
-@menu
-* New specification for Ada.Finalization.Controlled: New specification for Ada Finalization Controlled.
-* Finalized tagged types::
-* Composite types::
-* Interoperability with controlled types::
-
-@end menu
-
-@node New specification for Ada Finalization Controlled,Finalized tagged types,,No_Raise aspect
-@anchor{gnat_rm/gnat_language_extensions new-specification-for-ada-finalization-controlled}@anchor{468}
-@subsubsection New specification for @code{Ada.Finalization.Controlled}
-
-
-@code{Ada.Finalization.Controlled} is now specified as:
-
-@example
-type Controlled is abstract tagged null record
- with Initialize => Initialize,
- Adjust => Adjust,
- Finalize => Finalize,
- Legacy_Heap_Finalization, Exceptions_In_Finalize;
-
- procedure Initialize (Self : in out Controlled) is abstract;
- procedure Adjust (Self : in out Controlled) is abstract;
- procedure Finalize (Self : in out Controlled) is abstract;
-@end example
-
-### Examples
-
-A simple example of a ref-counted type:
+Simple example of ref-counted type:
@example
type T is record
- Value : Integer;
+ Value : Integer;
Ref_Count : Natural := 0;
end record;
@@ -31071,8 +31018,8 @@ type T_Access is access all T;
type T_Ref is record
Value : T_Access;
end record
- with Adjust => Adjust,
- Finalize => Finalize;
+ with Finalizable => (Adjust => Adjust,
+ Finalize => Finalize);
procedure Adjust (Ref : in out T_Ref) is
begin
@@ -31085,7 +31032,7 @@ begin
end Finalize;
@end example
-A simple file handle that ensures resources are properly released:
+Simple file handle that ensures resources are properly released:
@example
package P is
@@ -31094,66 +31041,64 @@ package P is
function Open (Path : String) return File;
procedure Close (F : in out File);
+
private
type File is limited record
Handle : ...;
end record
- with Finalize => Close;
+ with Finalizable (Finalize => Close);
+end P;
@end example
-@node Finalized tagged types,Composite types,New specification for Ada Finalization Controlled,No_Raise aspect
-@anchor{gnat_rm/gnat_language_extensions finalized-tagged-types}@anchor{469}
-@subsubsection Finalized tagged types
-
+@menu
+* Finalizable tagged types::
+* Composite types::
+* Interoperability with controlled types::
-Aspects are inherited by derived types and optionally overriden by those. The
-compiler-generated calls to the user-defined operations are then
-dispatching whenever it makes sense, i.e. the object in question is of
-class-wide type and the class includes at least one finalized tagged type.
+@end menu
-However note that for simplicity, it is forbidden to change the value of any of
-those new aspects in derived types.
+@node Finalizable tagged types,Composite types,,Generalized Finalization
+@anchor{gnat_rm/gnat_language_extensions finalizable-tagged-types}@anchor{467}
+@subsubsection Finalizable tagged types
-@node Composite types,Interoperability with controlled types,Finalized tagged types,No_Raise aspect
-@anchor{gnat_rm/gnat_language_extensions composite-types}@anchor{46a}
-@subsubsection Composite types
+The aspect is inherited by derived types and the primitives may be overridden
+by the derivation. The compiler-generated calls to these operations are then
+dispatching whenever it makes sense, i.e. when the object in question is of a
+class-wide type and the class includes at least one finalizable tagged type.
-When a finalized type is used as a component of a composite type, the latter
-becomes finalized as well. The three primitives are derived automatically
-in order to call the primitives of their components.
+@node Composite types,Interoperability with controlled types,Finalizable tagged types,Generalized Finalization
+@anchor{gnat_rm/gnat_language_extensions composite-types}@anchor{468}
+@subsubsection Composite types
-If that composite type was already user-finalized, then the compiler
-calls the primitives of the components so as to stay consistent with today’s
-controlled types’s behavior.
-So, @code{Initialize} and @code{Adjust} are called on components before they
-are called on the composite object, but @code{Finalize} is called on the composite
-object first.
+When a finalizable type is used as a component of a composite type, the latter
+becomes finalizable as well. The three primitives are derived automatically
+in order to call the primitives of their components. The dynamic semantics is
+the same as for controlled components of composite types.
-@node Interoperability with controlled types,,Composite types,No_Raise aspect
-@anchor{gnat_rm/gnat_language_extensions interoperability-with-controlled-types}@anchor{46b}
+@node Interoperability with controlled types,,Composite types,Generalized Finalization
+@anchor{gnat_rm/gnat_language_extensions interoperability-with-controlled-types}@anchor{469}
@subsubsection Interoperability with controlled types
-As a consequence of the redefinition of the @code{Controlled} type as a base type
-with the new aspects defined, interoperability with controlled type naturally
-follows the definition of the above rules. In particular:
-
+Finalizable types are fully interoperable with controlled types, in particular
+it is possible for a finalizable type to have a controlled component and vice
+versa, but the stricter dynamic semantics, in other words that of controlled
+types, is applied in this case.
-@itemize *
+@node No_Raise aspect,Inference of Dependent Types in Generic Instantiations,Generalized Finalization,Experimental Language Extensions
+@anchor{gnat_rm/gnat_language_extensions id3}@anchor{46a}@anchor{gnat_rm/gnat_language_extensions no-raise-aspect}@anchor{466}
+@subsection No_Raise aspect
-@item
-It is possible to have a new finalized type have a controlled type
-component
-@item
-It is possible to have a controlled type have a finalized type
-component
-@end itemize
+The @code{No_Raise} aspect can be applied to a subprogram to declare that this
+subprogram is not expected to raise an exception. Should an exception still
+be raised during the execution of the subprogram, it is caught at the end of
+this execution and @code{Program_Error} is propagated to the caller.
@node Inference of Dependent Types in Generic Instantiations,External_Initialization Aspect,No_Raise aspect,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions inference-of-dependent-types-in-generic-instantiations}@anchor{46c}
+@anchor{gnat_rm/gnat_language_extensions inference-of-dependent-types-in-generic-instantiations}@anchor{46b}
@subsection Inference of Dependent Types in Generic Instantiations
@@ -31230,7 +31175,7 @@ package Int_Array_Operations is new Array_Operations
@end example
@node External_Initialization Aspect,Finally construct,Inference of Dependent Types in Generic Instantiations,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions external-initialization-aspect}@anchor{46d}
+@anchor{gnat_rm/gnat_language_extensions external-initialization-aspect}@anchor{46c}
@subsection External_Initialization Aspect
@@ -31271,7 +31216,7 @@ The maximum size of loaded files is limited to 2@w{^31} bytes.
@end cartouche
@node Finally construct,,External_Initialization Aspect,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions finally-construct}@anchor{46e}
+@anchor{gnat_rm/gnat_language_extensions finally-construct}@anchor{46d}
@subsection Finally construct
@@ -31288,7 +31233,7 @@ This feature is similar to the one with the same name in other languages such as
@end menu
@node Syntax<2>,Legality Rules<2>,,Finally construct
-@anchor{gnat_rm/gnat_language_extensions id4}@anchor{46f}
+@anchor{gnat_rm/gnat_language_extensions id4}@anchor{46e}
@subsubsection Syntax
@@ -31303,7 +31248,7 @@ handled_sequence_of_statements ::=
@end example
@node Legality Rules<2>,Dynamic Semantics<2>,Syntax<2>,Finally construct
-@anchor{gnat_rm/gnat_language_extensions id5}@anchor{470}
+@anchor{gnat_rm/gnat_language_extensions id5}@anchor{46f}
@subsubsection Legality Rules
@@ -31313,7 +31258,7 @@ to be transferred outside the finally part are forbidden.
Goto & exit where the target is outside of the finally’s @code{sequence_of_statements} are forbidden
@node Dynamic Semantics<2>,,Legality Rules<2>,Finally construct
-@anchor{gnat_rm/gnat_language_extensions id6}@anchor{471}
+@anchor{gnat_rm/gnat_language_extensions id6}@anchor{470}
@subsubsection Dynamic Semantics
@@ -31328,7 +31273,7 @@ execution, that is the finally block must be executed in full even if the contai
aborted, or if the control is transferred out of the block.
@node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top
-@anchor{gnat_rm/security_hardening_features doc}@anchor{472}@anchor{gnat_rm/security_hardening_features id1}@anchor{473}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
+@anchor{gnat_rm/security_hardening_features doc}@anchor{471}@anchor{gnat_rm/security_hardening_features id1}@anchor{472}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
@chapter Security Hardening Features
@@ -31350,7 +31295,7 @@ change.
@end menu
@node Register Scrubbing,Stack Scrubbing,,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{474}
+@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{473}
@section Register Scrubbing
@@ -31386,7 +31331,7 @@ programming languages, see @cite{Using the GNU Compiler Collection (GCC)}.
@c Stack Scrubbing:
@node Stack Scrubbing,Hardened Conditionals,Register Scrubbing,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{475}
+@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{474}
@section Stack Scrubbing
@@ -31530,7 +31475,7 @@ Bar_Callable_Ptr.
@c Hardened Conditionals:
@node Hardened Conditionals,Hardened Booleans,Stack Scrubbing,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{476}
+@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{475}
@section Hardened Conditionals
@@ -31620,7 +31565,7 @@ be used with other programming languages supported by GCC.
@c Hardened Booleans:
@node Hardened Booleans,Control Flow Redundancy,Hardened Conditionals,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{477}
+@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{476}
@section Hardened Booleans
@@ -31681,7 +31626,7 @@ and more details on that attribute, see @cite{Using the GNU Compiler Collection
@c Control Flow Redundancy:
@node Control Flow Redundancy,,Hardened Booleans,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{478}
+@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{477}
@section Control Flow Redundancy
@@ -31849,7 +31794,7 @@ see @cite{Using the GNU Compiler Collection (GCC)}. These options
can be used with other programming languages supported by GCC.
@node Obsolescent Features,Compatibility and Porting Guide,Security Hardening Features,Top
-@anchor{gnat_rm/obsolescent_features doc}@anchor{479}@anchor{gnat_rm/obsolescent_features id1}@anchor{47a}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
+@anchor{gnat_rm/obsolescent_features doc}@anchor{478}@anchor{gnat_rm/obsolescent_features id1}@anchor{479}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
@chapter Obsolescent Features
@@ -31868,7 +31813,7 @@ compatibility purposes.
@end menu
@node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id2}@anchor{47b}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{47c}
+@anchor{gnat_rm/obsolescent_features id2}@anchor{47a}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{47b}
@section pragma No_Run_Time
@@ -31881,7 +31826,7 @@ preferred usage is to use an appropriately configured run-time that
includes just those features that are to be made accessible.
@node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id3}@anchor{47d}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{47e}
+@anchor{gnat_rm/obsolescent_features id3}@anchor{47c}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{47d}
@section pragma Ravenscar
@@ -31890,7 +31835,7 @@ The pragma @code{Ravenscar} has exactly the same effect as pragma
is part of the new Ada 2005 standard.
@node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id4}@anchor{47f}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{480}
+@anchor{gnat_rm/obsolescent_features id4}@anchor{47e}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{47f}
@section pragma Restricted_Run_Time
@@ -31900,7 +31845,7 @@ preferred since the Ada 2005 pragma @code{Profile} is intended for
this kind of implementation dependent addition.
@node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id5}@anchor{481}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{482}
+@anchor{gnat_rm/obsolescent_features id5}@anchor{480}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{481}
@section pragma Task_Info
@@ -31926,7 +31871,7 @@ in the spec of package System.Task_Info in the runtime
library.
@node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{483}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{484}
+@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{482}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{483}
@section package System.Task_Info (@code{s-tasinf.ads})
@@ -31936,7 +31881,7 @@ to support the @code{Task_Info} pragma. The predefined Ada package
standard replacement for GNAT’s @code{Task_Info} functionality.
@node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
-@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{485}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{486}
+@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{484}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{485}
@chapter Compatibility and Porting Guide
@@ -31958,7 +31903,7 @@ applications developed in other Ada environments.
@end menu
@node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{487}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{488}
+@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{486}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{487}
@section Writing Portable Fixed-Point Declarations
@@ -32080,7 +32025,7 @@ If you follow this scheme you will be guaranteed that your fixed-point
types will be portable.
@node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{489}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{48a}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{488}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{489}
@section Compatibility with Ada 83
@@ -32108,7 +32053,7 @@ following subsections treat the most likely issues to be encountered.
@end menu
@node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{48b}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{48c}
+@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{48a}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{48b}
@subsection Legal Ada 83 programs that are illegal in Ada 95
@@ -32208,7 +32153,7 @@ the fix is usually simply to add the @code{(<>)} to the generic declaration.
@end itemize
@node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{48d}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{48e}
+@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{48c}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{48d}
@subsection More deterministic semantics
@@ -32236,7 +32181,7 @@ which open select branches are executed.
@end itemize
@node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{48f}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{490}
+@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{48e}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{48f}
@subsection Changed semantics
@@ -32278,7 +32223,7 @@ covers only the restricted range.
@end itemize
@node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{491}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{492}
+@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{490}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{491}
@subsection Other language compatibility issues
@@ -32311,7 +32256,7 @@ include @code{pragma Interface} and the floating point type attributes
@end itemize
@node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{493}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{494}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{492}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{493}
@section Compatibility between Ada 95 and Ada 2005
@@ -32383,7 +32328,7 @@ can declare a function returning a value from an anonymous access type.
@end itemize
@node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{495}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{496}
+@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{494}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{495}
@section Implementation-dependent characteristics
@@ -32406,7 +32351,7 @@ transition from certain Ada 83 compilers.
@end menu
@node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{497}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{498}
+@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{496}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{497}
@subsection Implementation-defined pragmas
@@ -32428,7 +32373,7 @@ avoiding compiler rejection of units that contain such pragmas; they are not
relevant in a GNAT context and hence are not otherwise implemented.
@node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{499}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{49a}
+@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{498}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{499}
@subsection Implementation-defined attributes
@@ -32442,7 +32387,7 @@ Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
@code{Type_Class}.
@node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{49b}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{49c}
+@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{49a}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{49b}
@subsection Libraries
@@ -32471,7 +32416,7 @@ be preferable to retrofit the application using modular types.
@end itemize
@node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{49d}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{49e}
+@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{49c}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{49d}
@subsection Elaboration order
@@ -32507,7 +32452,7 @@ pragmas either globally (as an effect of the `-gnatE' switch) or locally
@end itemize
@node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{49f}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{4a0}
+@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{49e}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{49f}
@subsection Target-specific aspects
@@ -32520,10 +32465,10 @@ on the robustness of the original design. Moreover, Ada 95 (and thus
Ada 2005 and Ada 2012) are sometimes
incompatible with typical Ada 83 compiler practices regarding implicit
packing, the meaning of the Size attribute, and the size of access values.
-GNAT’s approach to these issues is described in @ref{4a1,,Representation Clauses}.
+GNAT’s approach to these issues is described in @ref{4a0,,Representation Clauses}.
@node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{4a2}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{4a3}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{4a1}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{4a2}
@section Compatibility with Other Ada Systems
@@ -32566,7 +32511,7 @@ far beyond this minimal set, as described in the next section.
@end itemize
@node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{4a4}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{4a1}
+@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{4a3}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{4a0}
@section Representation Clauses
@@ -32659,7 +32604,7 @@ with thin pointers.
@end itemize
@node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{4a5}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{4a6}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{4a4}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{4a5}
@section Compatibility with HP Ada 83
@@ -32689,7 +32634,7 @@ extension of package System.
@end itemize
@node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
-@anchor{share/gnu_free_documentation_license doc}@anchor{4a7}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{4a8}
+@anchor{share/gnu_free_documentation_license doc}@anchor{4a6}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{4a7}
@chapter GNU Free Documentation License
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 0a3cdb5..639708b 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -9850,7 +9850,7 @@ Treat pragma Restrictions as Restriction_Warnings.
@table @asis
-@item @code{-gnatR[0|1|2|3|4][e][j][m][s]}
+@item @code{-gnatR[0|1|2|3|4][e][h][m][j][s]}
Output representation information for declared types, objects and
subprograms. Note that this switch is not allowed if a previous
@@ -10076,7 +10076,7 @@ Library (RTL) ALI files.
@code{n} controls the optimization level:
-@multitable {xxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
+@multitable {xxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
@item
`n'
@@ -10091,7 +10091,7 @@ Effect
@tab
-No optimization, the default setting if no @code{-O} appears
+No optimization, the default setting if no @code{-O} appears.
@item
@@ -10099,9 +10099,8 @@ No optimization, the default setting if no @code{-O} appears
@tab
-Normal optimization, the default if you specify @code{-O} without an
-operand. A good compromise between code quality and compilation
-time.
+Moderate optimization, same as @code{-O} without an operand.
+A good compromise between code quality and compilation time.
@item
@@ -10109,7 +10108,7 @@ time.
@tab
-Extensive optimization, may improve execution time, possibly at
+Extensive optimization, should improve execution time, possibly at
the cost of substantially increased compilation time.
@item
@@ -10118,8 +10117,8 @@ the cost of substantially increased compilation time.
@tab
-Same as @code{-O2}, and also includes inline expansion for small
-subprograms in the same unit.
+Full optimization, may further improve execution time, possibly at
+the cost of substantially larger generated code.
@item
@@ -10127,7 +10126,23 @@ subprograms in the same unit.
@tab
-Optimize space usage
+Optimize for size (code and data) rather than speed.
+
+@item
+
+`z'
+
+@tab
+
+Optimize aggressively for size (code and data) rather than speed.
+
+@item
+
+`g'
+
+@tab
+
+Optimize for debugging experience rather than speed.
@end multitable
@@ -15270,7 +15285,7 @@ restriction warnings rather than restrictions.
@table @asis
-@item @code{-gnatR[0|1|2|3|4][e][j][m][s]}
+@item @code{-gnatR[0|1|2|3|4][e][h][m][j][s]}
This switch controls output from the compiler of a listing showing
representation information for declared types, objects and subprograms.
@@ -15299,17 +15314,21 @@ If the switch is followed by an @code{e} (e.g. @code{-gnatR2e}), then
extended representation information for record sub-components of records
is included.
+If the switch is followed by a @code{h} (e.g. @code{-gnatR3h}), then
+the components of records are sorted by increasing offsets and holes
+between consecutive components are flagged.
+
If the switch is followed by an @code{m} (e.g. @code{-gnatRm}), then
subprogram conventions and parameter passing mechanisms for all the
subprograms are included.
-If the switch is followed by a @code{j} (e.g., @code{-gnatRj}), then
+If the switch is followed by a @code{j} (e.g. @code{-gnatRj}), then
the output is in the JSON data interchange format specified by the
ECMA-404 standard. The semantic description of this JSON output is
available in the specification of the Repinfo unit present in the
compiler sources.
-If the switch is followed by an @code{s} (e.g., @code{-gnatR3s}), then
+If the switch is followed by an @code{s} (e.g. @code{-gnatR3s}), then
the output is to a file with the name @code{file.rep} where @code{file} is
the name of the corresponding source file, except if @code{j} is also
specified, in which case the file name is @code{file.json}.
@@ -20281,13 +20300,12 @@ Turning on optimization makes the compiler attempt to improve the
performance and/or code size at the expense of compilation time and
possibly the ability to debug the program.
-If you use multiple @code{-O} switches, with or without level
-numbers, the last such switch is the one that’s used.
-
-You can use the
-@code{-O} switch (the permitted forms are @code{-O0}, @code{-O1}
-@code{-O2}, @code{-O3}, and @code{-Os})
-to @code{gcc} to control the optimization level:
+You can pass the @code{-O} switch, with or without an operand
+(the permitted forms with an operand are @code{-O0}, @code{-O1},
+@code{-O2}, @code{-O3}, @code{-Os}, @code{-Oz}, and
+@code{-Og}) to @code{gcc} to control the optimization level. If you
+pass multiple @code{-O} switches, with or without an operand,
+the last such switch is the one that’s used:
@itemize *
@@ -20298,8 +20316,7 @@ to @code{gcc} to control the optimization level:
@item @code{-O0}
-No optimization (the default);
-generates unoptimized code but has
+No optimization (the default); generates unoptimized code but has
the fastest compilation time. Debugging is easiest with this switch.
Note that many other compilers do substantial optimization even if
@@ -20316,10 +20333,11 @@ mind when doing performance comparisons.
@item @code{-O1}
-Moderate optimization; optimizes reasonably well but does not
-degrade compilation time significantly. You may not be able to see
-some variables in the debugger and changing the value of some
-variables in the debugger may not have the effect you desire.
+Moderate optimization (same as @code{-O} without an operand);
+optimizes reasonably well but does not degrade compilation time
+significantly. You may not be able to see some variables in the
+debugger, and changing the value of some variables in the debugger
+may not have the effect you desire.
@end table
@item
@@ -20328,9 +20346,8 @@ variables in the debugger may not have the effect you desire.
@item @code{-O2}
-Full optimization;
-generates highly optimized code and has
-the slowest compilation time. You may see significant impacts on
+Extensive optimization; generates highly optimized code but has
+an increased compilation time. You may see significant impacts on
your ability to display and modify variables in the debugger.
@end table
@@ -20340,9 +20357,9 @@ your ability to display and modify variables in the debugger.
@item @code{-O3}
-Full optimization as in @code{-O2};
-also uses more aggressive automatic inlining of subprograms within a unit
-(@ref{104,,Inlining of Subprograms}) and attempts to vectorize loops.
+Full optimization; attempts more sophisticated transformations, in
+particular on loops, possibly at the cost of larger generated code.
+You may be hardly able to use the debugger at this optimization level.
@end table
@item
@@ -20351,16 +20368,41 @@ also uses more aggressive automatic inlining of subprograms within a unit
@item @code{-Os}
-Optimize space usage (code and data) of resulting program.
+Optimize for size (code and data) of resulting binary rather than
+speed; based on the @code{-O2} optimization level, but disables
+some of its transformations that often increase code size, as well
+as performs further optimizations designed to reduce code size.
+@end table
+
+@item
+
+@table @asis
+
+@item @code{-Oz}
+
+Optimize aggressively for size (code and data) of resulting binary
+rather than speed; may increase the number of instructions executed
+if these instructions require fewer bytes to be encoded.
+@end table
+
+@item
+
+@table @asis
+
+@item @code{-Og}
+
+Optimize for debugging experience rather than speed; based on the
+@code{-O1} optimization level, but attempts to eliminate all the
+negative effects of optimization on debugging.
@end table
@end itemize
Higher optimization levels perform more global transformations on the
program and apply more expensive analysis algorithms in order to generate
faster and more compact code. The price in compilation time, and the
-resulting improvement in execution time,
-both depend on the particular application and the hardware environment.
-You should experiment to find the best level for your application.
+resulting improvement in execution time, both depend on the particular
+application and the hardware environment. You should experiment to find
+the best level for your application.
Since the precise set of optimizations done at each level will vary from
release to release (and sometime from target to target), it is best to think
diff --git a/gcc/ada/gnatcmd.adb b/gcc/ada/gnatcmd.adb
index 546dbca..5e3802e 100644
--- a/gcc/ada/gnatcmd.adb
+++ b/gcc/ada/gnatcmd.adb
@@ -368,7 +368,7 @@ begin
-- --help flag.
Set_Standard_Output;
Write_Eol;
- Write_Line ("Report bugs to report@adacore.com");
+ Write_Line ("Report bugs to support@adacore.com");
return;
end if;
diff --git a/gcc/ada/libgnat/s-secsta.adb b/gcc/ada/libgnat/s-secsta.adb
index 2749658..9d78b86 100644
--- a/gcc/ada/libgnat/s-secsta.adb
+++ b/gcc/ada/libgnat/s-secsta.adb
@@ -633,6 +633,15 @@ package body System.Secondary_Stack is
if Over_Aligning then
Padding := Alignment;
+
+ -- Typically the padding would be
+ -- Alignment - (Addr mod Alignment)
+ -- however Addr in this case is not known yet. It depends on the
+ -- type of the secondary stack (Dynamic/Static). The allocation
+ -- routine for the respective type of stack requires to know the
+ -- allocation size before the address is known. To ensure a
+ -- sufficient allocation size to fit the padding, the padding is
+ -- calculated conservatively.
end if;
-- Round the requested size (plus the needed padding in case of
diff --git a/gcc/ada/libgnat/s-secsta__cheri.adb b/gcc/ada/libgnat/s-secsta__cheri.adb
index a24b50e..9a65ed28 100644
--- a/gcc/ada/libgnat/s-secsta__cheri.adb
+++ b/gcc/ada/libgnat/s-secsta__cheri.adb
@@ -662,6 +662,15 @@ package body System.Secondary_Stack is
if Over_Aligning then
Over_Align_Padding := Alignment;
+
+ -- Typically the padding would be
+ -- Alignment - (Addr mod Alignment)
+ -- however Addr in this case is not known yet. It depends on the
+ -- type of the secondary stack (Dynamic/Static). The allocation
+ -- routine for the respective type of stack requires to know the
+ -- allocation size before the address is known. To ensure a
+ -- sufficient allocation size to fit the padding, the padding is
+ -- calculated conservatively.
end if;
-- It should not be possible to request an allocation of negative
diff --git a/gcc/ada/libgnat/s-valuef.adb b/gcc/ada/libgnat/s-valuef.adb
index 9930740..7baa3b3 100644
--- a/gcc/ada/libgnat/s-valuef.adb
+++ b/gcc/ada/libgnat/s-valuef.adb
@@ -156,6 +156,9 @@ package body System.Value_F is
pragma Assert (Num < 0 and then Den < 0);
-- Accept only negative numbers to allow -2**(Int'Size - 1)
+ pragma Unsuppress (Overflow_Check);
+ -- Use overflow check to catch bad values
+
function Safe_Expont
(Base : Int;
Exp : in out Natural;
@@ -224,38 +227,52 @@ package body System.Value_F is
B : constant Int := Int (Base);
- V : Uns := Val;
- E : Uns := Uns (Extra);
+ V : Uns := Val;
+ S : Integer := ScaleB;
+ E : Uns := Uns (Extra);
Y, Z, Q1, R1, Q2, R2 : Int;
begin
+ -- The implementation of Value_R uses fully symmetric arithmetics
+ -- but here we cannot handle 2**(Int'Size - 1) if Minus is not set.
+
+ if V = 2**(Int'Size - 1) and then not Minus then
+ E := V rem Uns (B);
+ V := V / Uns (B);
+ S := S + 1;
+ end if;
+
-- We will use a scaled divide operation for which we must control the
-- magnitude of operands so that an overflow exception is not unduly
-- raised during the computation. The only real concern is the exponent.
- -- If ScaleB is too negative, then drop trailing digits, but preserve
- -- the last dropped digit.
+ -- If S is too negative, then drop trailing digits, but preserve the
+ -- last dropped digit, until V saturates to 0.
- if ScaleB < 0 then
+ if S < 0 then
declare
- LS : Integer := -ScaleB;
+ LS : Integer := -S;
begin
Y := Den;
Z := Safe_Expont (B, LS, Num);
for J in 1 .. LS loop
+ if V = 0 then
+ E := 0;
+ exit;
+ end if;
E := V rem Uns (B);
V := V / Uns (B);
end loop;
end;
- -- If ScaleB is too positive, then scale V up, which may then overflow
+ -- If S is too positive, then scale V up, which may then overflow
- elsif ScaleB > 0 then
+ elsif S > 0 then
declare
- LS : Integer := ScaleB;
+ LS : Integer := S;
begin
Y := Safe_Expont (B, LS, Den);
@@ -271,7 +288,7 @@ package body System.Value_F is
end loop;
end;
- -- If ScaleB is zero, then proceed directly
+ -- If S is zero, then proceed directly
else
Y := Den;
diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb
index 6f557e9..cc1f778 100644
--- a/gcc/ada/libgnat/s-valuer.adb
+++ b/gcc/ada/libgnat/s-valuer.adb
@@ -135,7 +135,9 @@ package body System.Value_R is
B : constant Uns := Uns (Base);
begin
- if Digit >= Base / 2 then
+ -- Beware that Base may be odd
+
+ if 2 * Unsigned (Digit) >= Base then
-- If Extra is maximum, round Value
@@ -578,8 +580,8 @@ package body System.Value_R is
if Str (Index) in '0' .. '9' then
After_Point := False;
- -- If this is a digit it can indicates either the float decimal
- -- part or the base to use.
+ -- If this is a digit it can indicate either the integral part or the
+ -- base to use.
Scan_Integral_Digits
(Str, Index, Max, Base, False, Value, Scale, N,
@@ -602,7 +604,8 @@ package body System.Value_R is
Bad_Value (Str);
end if;
- -- Check if the first number encountered is a base
+ -- Check if the first number encountered is a base. ':' is allowed in
+ -- place of '#' in virtue of RM J.2 (3).
pragma Assert (Index >= Str'First);
@@ -611,7 +614,13 @@ package body System.Value_R is
then
Base_Char := Str (Index);
- if N = 1 and then Value (1) in 2 .. 16 then
+ -- Functionally, "(Parts = 1 or else N = 1)" in the condition of the
+ -- following if statement could replaced by the simpler "N = 1". The
+ -- reason we use a more complicated expression is to accommodate
+ -- machine-code-based coverage tools: the simple version makes it
+ -- impossible to fully cover generic instances of System.Value_R with
+ -- Parts = 1.
+ if (Parts = 1 or else N = 1) and then Value (1) in 2 .. 16 then
Base := Unsigned (Value (1));
else
Base_Violation := True;
@@ -630,10 +639,10 @@ package body System.Value_R is
end if;
end if;
- -- Scan the integral part if still necessary
+ -- Scan the integral part if there was a base and no point right after
if Base_Char /= ASCII.NUL and then not After_Point then
- if Index > Max or else As_Digit (Str (Index)) not in Valid_Digit then
+ if As_Digit (Str (Index)) not in Valid_Digit then
Bad_Value (Str);
end if;
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index cbe4701..e595b08 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -943,6 +943,21 @@ package Opt is
-- WARNING: There is a matching C declaration of this variable in fe.h
+ List_Representation_Info_Extended : Boolean := False;
+ -- GNAT
+ -- Set true by -gnatRe switch. Causes extended information for record types
+ -- to be included in the representation output information.
+
+ List_Representation_Info_Holes : Boolean := False;
+ -- GNAT
+ -- Set true by -gnatRh switch. Causes information for holes between record
+ -- components to be included in the representation output information.
+
+ List_Representation_Info_Mechanisms : Boolean := False;
+ -- GNAT
+ -- Set true by -gnatRm switch. Causes information on mechanisms to be
+ -- included in the representation output information.
+
List_Representation_Info_To_File : Boolean := False;
-- GNAT
-- Set true by -gnatRs switch. Causes information from -gnatR[1-4]m to be
@@ -955,16 +970,6 @@ package Opt is
-- Set true by -gnatRj switch. Causes information from -gnatR[1-4]m to be
-- output in the JSON data interchange format.
- List_Representation_Info_Mechanisms : Boolean := False;
- -- GNAT
- -- Set true by -gnatRm switch. Causes information on mechanisms to be
- -- included in the representation output information.
-
- List_Representation_Info_Extended : Boolean := False;
- -- GNAT
- -- Set true by -gnatRe switch. Causes extended information for record types
- -- to be included in the representation output information.
-
List_Preprocessing_Symbols : Boolean := False;
-- GNAT, GNATPREP
-- Set to True if symbols for preprocessing a source are to be listed
diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb
index a6dff7c..ddbb58e 100644
--- a/gcc/ada/repinfo.adb
+++ b/gcc/ada/repinfo.adb
@@ -30,6 +30,7 @@ with Debug; use Debug;
with Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
+with GNAT.Heap_Sort_G;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
@@ -413,9 +414,9 @@ package body Repinfo is
Write_Line (";");
end if;
- -- Alignment is not always set for task, protected, and class-wide
- -- types, or when doing semantic analysis only. Representation aspects
- -- are not computed for types in a generic unit.
+ -- Alignment is not always set for concurrent types, class-wide types,
+ -- cloned subtypes, or when doing semantic analysis only. Representation
+ -- aspects are not computed for types declared in a generic unit.
else
-- Add unknown alignment entry in JSON format to ensure the format is
@@ -426,11 +427,13 @@ package body Repinfo is
Write_Unknown_Val;
end if;
- pragma Assert
- (not Expander_Active or else
- Is_Concurrent_Type (Ent) or else
- Is_Class_Wide_Type (Ent) or else
- Sem_Util.In_Generic_Scope (Ent));
+ pragma Assert (not Expander_Active
+ or else Is_Concurrent_Type (Ent)
+ or else Is_Class_Wide_Type (Ent)
+ or else (Ekind (Ent) = E_Record_Subtype
+ and then Present (Cloned_Subtype (Ent))
+ and then Has_Delayed_Freeze (Cloned_Subtype (Ent)))
+ or else Sem_Util.In_Generic_Scope (Ent));
end if;
end List_Common_Type_Info;
@@ -856,8 +859,7 @@ package body Repinfo is
-- generic unit, or if the back end is not being run), don't try to
-- print them.
- pragma Assert (Known_Esize (Ent) = Known_Alignment (Ent));
- if not Known_Alignment (Ent) then
+ if not Known_Esize (Ent) or else not Known_Alignment (Ent) then
return;
end if;
@@ -882,6 +884,7 @@ package body Repinfo is
Write_Eol;
Write_Line ("}");
+
else
Write_Str ("for ");
List_Name (Ent);
@@ -1223,11 +1226,135 @@ package body Repinfo is
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "")
is
- Comp : Entity_Id;
- First : Boolean := True;
+ function First_Comp_Or_Discr (Ent : Entity_Id) return Entity_Id;
+ -- Like First_Component_Or_Discriminant, but reorder the components
+ -- according to their bit offset if need be.
+
+ -------------------------
+ -- First_Comp_Or_Discr --
+ -------------------------
+
+ function First_Comp_Or_Discr (Ent : Entity_Id) return Entity_Id is
+
+ function Is_Placed_Before (C1, C2 : Entity_Id) return Boolean;
+ -- Return True if component C1 is placed before component C2
+
+ ----------------------
+ -- Is_Placed_Before --
+ ----------------------
+
+ function Is_Placed_Before (C1, C2 : Entity_Id) return Boolean is
+ begin
+ return Known_Static_Component_Bit_Offset (C1)
+ and then Known_Static_Component_Bit_Offset (C2)
+ and then
+ Component_Bit_Offset (C1) < Component_Bit_Offset (C2);
+ end Is_Placed_Before;
+
+ -- Local variables
+
+ Comp : Entity_Id;
+ N_Comp : Natural := 0;
+ Prev : Entity_Id;
+ Reorder : Boolean := False;
+
+ -- Start of processing for First_Comp_Or_Discr
+
+ begin
+ -- Reordering is needed only for -gnatRh
+
+ if not List_Representation_Info_Holes then
+ return First_Component_Or_Discriminant (Ent);
+ end if;
+
+ -- Count the number of components and whether reordering is needed
+
+ Comp := First_Component_Or_Discriminant (Ent);
+ Prev := Comp;
+
+ while Present (Comp) loop
+ N_Comp := N_Comp + 1;
+
+ if not Reorder then
+ Reorder := Is_Placed_Before (Comp, Prev);
+ end if;
+
+ Prev := Comp;
+ Next_Component_Or_Discriminant (Comp);
+ end loop;
+
+ -- Reorder the components, if need be, by directly reshuffling the
+ -- list of entities between First_Entity and Last_Entity, which is
+ -- safe because we are invoked after compilation is finished.
+
+ if Reorder then
+ declare
+ Comps : array (Natural range 0 .. N_Comp) of Entity_Id;
+ -- Support array for the heapsort
+
+ function Lt (Op1, Op2 : Natural) return Boolean is
+ (Is_Placed_Before (Comps (Op1), Comps (Op2)));
+ -- Compare function for the heapsort
+
+ procedure Move (From : Natural; To : Natural);
+ pragma Inline (Move);
+ -- Move procedure for the heapsort
+
+ ----------
+ -- Move --
+ ----------
+
+ procedure Move (From : Natural; To : Natural) is
+ begin
+ Comps (To) := Comps (From);
+ end Move;
+
+ package HS is new GNAT.Heap_Sort_G (Lt => Lt, Move => Move);
+ -- The heapsort for record components
+
+ begin
+ -- Pack the components into the array
+
+ N_Comp := 0;
+ Comp := First_Component_Or_Discriminant (Ent);
+
+ while Present (Comp) loop
+ N_Comp := N_Comp + 1;
+ Comps (N_Comp) := Comp;
+
+ Next_Component_Or_Discriminant (Comp);
+ end loop;
+
+ -- Sort the array
+
+ HS.Sort (N_Comp);
+
+ -- Unpack the component into the list of entities
+
+ Set_First_Entity (Ent, Comps (1));
+ Set_Prev_Entity (Comps (1), Empty);
+ for J in 1 .. N_Comp - 1 loop
+ Set_Next_Entity (Comps (J), Comps (J + 1));
+ Set_Prev_Entity (Comps (J + 1), Comps (J));
+ end loop;
+ Set_Next_Entity (Comps (N_Comp), Empty);
+ Set_Last_Entity (Ent, Comps (N_Comp));
+ end;
+ end if;
+
+ return First_Component_Or_Discriminant (Ent);
+ end First_Comp_Or_Discr;
+
+ -- Local variables
+
+ Bit_Offset : Uint := Uint_0;
+ Comp : Entity_Id;
+ First : Boolean := True;
+
+ -- Start of processing for List_Record_Layout
begin
- Comp := First_Component_Or_Discriminant (Ent);
+ Comp := First_Comp_Or_Discr (Ent);
while Present (Comp) loop
-- Skip a completely hidden discriminant or a discriminant in an
@@ -1237,69 +1364,98 @@ package body Repinfo is
and then (Is_Completely_Hidden (Comp)
or else Is_Unchecked_Union (Ent))
then
- goto Continue;
- end if;
+ null;
-- Skip _Parent component in extension (to avoid overlap)
- if Chars (Comp) = Name_uParent then
- goto Continue;
- end if;
+ elsif Chars (Comp) = Name_uParent then
+ null;
-- All other cases
- declare
- Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
- Npos : constant Uint := Normalized_Position (Comp);
- Fbit : constant Uint := Normalized_First_Bit (Comp);
- Spos : Uint;
- Sbit : Uint;
+ else
+ declare
+ C : constant Entity_Id :=
+ (if Known_Normalized_Position (Comp)
+ then Comp
+ else Original_Record_Component (Comp));
+ -- The Parent_Subtype in an extension is not back-annotated
+ -- but its layout is the same as that of the parent type.
- begin
- Get_Decoded_Name_String (Chars (Comp));
- Set_Casing (Unit_Casing);
+ Ctyp : constant Entity_Id := Underlying_Type (Etype (C));
- -- If extended information is requested, recurse fully into
- -- record components, i.e. skip the outer level.
+ begin
+ Get_Decoded_Name_String (Chars (C));
+ Set_Casing (Unit_Casing);
- if List_Representation_Info_Extended
- and then Is_Record_Type (Ctyp)
- and then Known_Static_Normalized_Position (Comp)
- and then Known_Static_Normalized_First_Bit (Comp)
- then
- Spos := Starting_Position + Npos;
- Sbit := Starting_First_Bit + Fbit;
+ -- If extended information is requested, recurse fully into
+ -- record components, i.e. skip the outer level.
- if Sbit >= SSU then
- Spos := Spos + 1;
- Sbit := Sbit - SSU;
- end if;
+ if List_Representation_Info_Extended
+ and then Is_Record_Type (Ctyp)
+ and then Known_Static_Normalized_Position (C)
+ and then Known_Static_Normalized_First_Bit (C)
+ then
+ declare
+ Npos : constant Uint := Normalized_Position (C);
+ Fbit : constant Uint := Normalized_First_Bit (C);
+ Pref : constant String :=
+ Prefix & Name_Buffer (1 .. Name_Len) & ".";
- List_Record_Layout (Ctyp,
- Spos, Sbit, Prefix & Name_Buffer (1 .. Name_Len) & ".");
+ Spos : Uint;
+ Sbit : Uint;
- goto Continue;
- end if;
+ begin
+ Spos := Starting_Position + Npos;
+ Sbit := Starting_First_Bit + Fbit;
+
+ if Sbit >= SSU then
+ Spos := Spos + 1;
+ Sbit := Sbit - SSU;
+ end if;
+
+ List_Record_Layout (Ctyp, Spos, Sbit, Pref);
+ end;
- if List_Representation_Info_To_JSON then
- if First then
- Write_Eol;
- First := False;
else
- Write_Line (",");
- end if;
- end if;
+ if List_Representation_Info_To_JSON then
+ if First then
+ Write_Eol;
+ First := False;
+ else
+ Write_Line (",");
+ end if;
+ end if;
- -- The Parent_Subtype in an extension is not back-annotated
+ -- If information about holes is requested, update the
+ -- current bit offset and report any (static) gap.
- List_Component_Layout (
- (if Known_Normalized_Position (Comp)
- then Comp
- else Original_Record_Component (Comp)),
- Starting_Position, Starting_First_Bit, Prefix);
- end;
+ if List_Representation_Info_Holes
+ and then Known_Static_Component_Bit_Offset (C)
+ then
+ declare
+ Gap : constant Uint :=
+ Component_Bit_Offset (C) - Bit_Offset;
+ begin
+ if Gap > Uint_0 then
+ Write_Str (" -- ");
+ UI_Write (Gap, Decimal);
+ Write_Line (" bits unused --");
+ end if;
+
+ if Known_Static_Esize (C) then
+ Bit_Offset :=
+ Component_Bit_Offset (C) + Esize (C);
+ end if;
+ end;
+ end if;
+
+ List_Component_Layout
+ (C, Starting_Position, Starting_First_Bit, Prefix);
+ end if;
+ end;
+ end if;
- <<Continue>>
Next_Component_Or_Discriminant (Comp);
end loop;
end List_Record_Layout;
@@ -1610,6 +1766,17 @@ package body Repinfo is
end loop;
end List_Structural_Record_Layout;
+ -- Use the original record type giving the layout of components
+ -- to avoid repeated reordering when -gnatRh is specified.
+
+ Rec : constant Entity_Id :=
+ (if Ekind (Ent) = E_Record_Subtype
+ and then Present (Cloned_Subtype (Ent))
+ then (if Is_Private_Type (Cloned_Subtype (Ent))
+ then Full_View (Cloned_Subtype (Ent))
+ else Cloned_Subtype (Ent))
+ else Ent);
+
-- Start of processing for List_Record_Info
begin
@@ -1624,7 +1791,7 @@ package body Repinfo is
-- First find out max line length and max starting position
-- length, for the purpose of lining things up nicely.
- Compute_Max_Length (Ent);
+ Compute_Max_Length (Rec);
-- Then do actual output based on those values
@@ -1636,21 +1803,21 @@ package body Repinfo is
-- declared in the extended main source unit for the time being,
-- because otherwise declarations might not be processed at all.
- if Is_Base_Type (Ent) then
+ if Is_Base_Type (Rec) then
begin
- List_Structural_Record_Layout (Ent, Ent);
+ List_Structural_Record_Layout (Rec, Rec);
exception
when Incomplete_Layout
| Not_In_Extended_Main
=>
- List_Record_Layout (Ent);
+ List_Record_Layout (Rec);
when others =>
raise Program_Error;
end;
else
- List_Record_Layout (Ent);
+ List_Record_Layout (Rec);
end if;
Write_Eol;
@@ -1660,7 +1827,7 @@ package body Repinfo is
List_Name (Ent);
Write_Line (" use record");
- List_Record_Layout (Ent);
+ List_Record_Layout (Rec);
Write_Line ("end record;");
end if;
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 1d94780..062251f 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -479,18 +479,19 @@ package body Sem_Ch12 is
-- Create a new access type with the given designated type
function Analyze_Associations
- (I_Node : Node_Id;
+ (N : Node_Id;
Formals : List_Id;
F_Copy : List_Id) return List_Id;
-- At instantiation time, build the list of associations between formals
-- and actuals. Each association becomes a renaming declaration for the
- -- formal entity. F_Copy is the analyzed list of formals in the generic
- -- copy. It is used to apply legality checks to the actuals. I_Node is the
- -- instantiation node.
+ -- formal entity. N is the instantiation node. Formals is the list of
+ -- unanalyzed formals. F_Copy is the analyzed list of formals in the
+ -- generic copy.
procedure Analyze_Subprogram_Instantiation
(N : Node_Id;
K : Entity_Kind);
+ -- Analyze subprogram instantiation N, either a function or a procedure
procedure Build_Instance_Compilation_Unit_Nodes
(N : Node_Id;
@@ -609,12 +610,12 @@ package body Sem_Ch12 is
(Inner : Entity_Id;
Outer : Entity_Id;
N : Node_Id) return Boolean;
- -- Inner is instantiated within the generic Outer. Check whether Inner
- -- directly or indirectly contains an instance of Outer or of one of its
- -- parents, in the case of a subunit. Each generic unit holds a list of
- -- the entities instantiated within (at any depth). This procedure
- -- determines whether the set of such lists contains a cycle, i.e. an
- -- illegal circular instantiation.
+ -- Inner is being instantiated within Outer. If Outer is also a generic
+ -- unit, check whether Inner directly or indirectly contains an instance
+ -- of Outer or of one of its parents (case of subunit). Each generic unit
+ -- holds a list of the entities instantiated within (at any depth). This
+ -- procedure determines whether the set of such lists contains a cycle,
+ -- i.e. an illegal circular instantiation.
function Denotes_Formal_Package
(Pack : Entity_Id;
@@ -1009,8 +1010,8 @@ package body Sem_Ch12 is
procedure Set_Next_Assoc (E : Assoc_Ptr; Next : Assoc_Ptr);
function Next_Assoc (E : Assoc_Ptr) return Assoc_Ptr;
- function Get_Gen_Id (E : Assoc_Ptr) return Entity_Id;
- function Hash (F : Entity_Id) return HTable_Range;
+ function Get_Gen_Id (E : Assoc_Ptr) return Entity_Id;
+ function Hash (F : Entity_Id) return HTable_Range;
package Generic_Renamings_HTable is new GNAT.HTable.Static_HTable (
Header_Num => HTable_Range,
@@ -1158,19 +1159,29 @@ package body Sem_Ch12 is
-- kinds for N_Box_Subp_Default, N_Box_Actual, N_Null_Default, and
-- N_Exp_Func_Default.
- type Generic_Actual_Rec (Kind : Actual_Kind := None) is record
- -- Representation of one generic actual parameter
+ type Actual_Rec (Kind : Actual_Kind := None) is record
case Kind is
- when None | None_Use_Clause | Box_Subp_Default | Box_Actual |
- Null_Default | Dummy_Assoc =>
+ when None
+ | None_Use_Clause
+ | Box_Subp_Default
+ | Box_Actual
+ | Null_Default
+ | Dummy_Assoc
+ =>
null;
- when Name_Exp | Exp_Func_Default =>
+ when Name_Exp
+ | Exp_Func_Default
+ =>
Name_Exp : Node_Id;
end case;
end record;
+ -- Representation of one generic actual parameter
type Actual_Origin_Enum is
- (None, From_Explicit_Actual, From_Default, From_Inference,
+ (None,
+ From_Explicit_Actual,
+ From_Default,
+ From_Inference,
From_Others_Box);
-- Indication of where the Actual came from -- explicitly in the
-- instantiation, inferred from some other type, or defaulted.
@@ -1179,16 +1190,16 @@ package body Sem_Ch12 is
-- Reason an actual type corresponding to a formal type was (or could
-- be) inferred from the actual type corresponding to another formal
-- type.
- (Designated_Type, -- designated type from formal access
- Index_Type, -- index type from formal array
- Component_Type, -- component type from formal array
+ (Designated_Type, -- designated type from formal access
+ Index_Type, -- index type from formal array
+ Component_Type, -- component type from formal array
Discriminant_Type); -- discriminant type from formal discriminated
function Image (Reason : Inference_Reason) return String is
(case Reason is
- when Designated_Type => "designated type",
- when Index_Type => "index type",
- when Component_Type => "component type",
+ when Designated_Type => "designated type",
+ when Index_Type => "index type",
+ when Component_Type => "component type",
when Discriminant_Type => "discriminant type");
type Assoc_Index is new Pos;
@@ -1210,7 +1221,7 @@ package body Sem_Ch12 is
Explicit_Assoc : Opt_N_Generic_Association_Id;
-- Explicit association, if any, from the source or generated.
- Actual : Generic_Actual_Rec;
+ Actual : Actual_Rec;
-- Generic actual parameter corresponding to Un_Formal/An_Formal,
-- possibly from defaults or others/boxes.
@@ -1224,7 +1235,7 @@ package body Sem_Ch12 is
-- inferred.
Inferred_From : Assoc_Index;
- -- Index of a later Assoc_Rec in the same Gen_Assocs_Rec from which
+ -- Index of a later Assoc_Rec in the same Match_Rec from which
-- this one was inferred, or could be inferred.
-- Valid only if Info_Inferred_Actual is present.
@@ -1237,10 +1248,10 @@ package body Sem_Ch12 is
-- One element for each formal and (if legal) for each corresponding
-- actual.
- type Gen_Assocs_Rec (Num_Assocs : Assoc_Count) is record
- -- Representation of formal/actual matching. Num_Assocs
- -- is the number of formals and (if legal) the number
- -- of actuals.
+ type Match_Rec (Num_Assocs : Assoc_Count) is record
+ -- Representation of formal/actual matching. Num_Assocs is the
+ -- number of formals and (if legal) the number of actuals.
+
Gen_Unit : Entity_Id;
-- the generic unit being instantiated
Others_Present : Boolean;
@@ -1251,25 +1262,26 @@ package body Sem_Ch12 is
end record;
function Match_Assocs
- (I_Node : Node_Id; Formals : List_Id; F_Copy : List_Id)
- return Gen_Assocs_Rec;
- -- I_Node is the instantiation node. Formals is the list of unanalyzed
+ (N : Node_Id;
+ Formals : List_Id;
+ F_Copy : List_Id) return Match_Rec;
+ -- N is the instantiation node. Formals is the list of unanalyzed
-- formals. F_Copy is the analyzed list of formals in the generic copy.
- -- Return a Gen_Assocs_Rec with formals, explicit actuals, and default
+ -- Return a Match_Rec with formals, explicit actuals, and default
-- actuals filled in. Check legality rules related to formal/actual
-- matching.
procedure Note_Potential_Inference
- (I_Node : Node_Id; Gen_Assocs : Gen_Assocs_Rec);
+ (N : Node_Id;
+ Match : Match_Rec);
-- If -gnatd_I, print "info:" messages about type inference that could
-- have been done.
end Associations;
procedure Analyze_One_Association
- (I_Node : Node_Id; -- instantiation node
- Assoc : Associations.Assoc_Rec;
- -- Logical 'in out' parameters:
+ (N : Node_Id;
+ Assoc : Associations.Assoc_Rec;
Result_Renamings : List_Id;
Default_Actuals : List_Id;
Actuals_To_Freeze : Elist_Id);
@@ -1279,12 +1291,12 @@ package body Sem_Ch12 is
-- appended onto Actuals_To_Freeze.
procedure Check_Fixed_Point_Warning
- (Gen_Assocs : Associations.Gen_Assocs_Rec;
+ (Match : Associations.Match_Rec;
Renamings : List_Id);
-- Warn if any actual is a fixed-point type that has user-defined
-- arithmetic operators, but there is no corresponding formal in the
-- generic, in which case the predefined operators will be used. This
- -- merits a warning because of the special semantics of fixed point
+ -- deserves a warning because of the special semantics of fixed point
-- operators. However, do not warn if the formal is private, because there
-- can be no arithmetic operators in the generic so there no danger of
-- confusion.
@@ -1315,27 +1327,29 @@ package body Sem_Ch12 is
-- analyzed formals in cases where there are multiple ones
-- corresponding to a particular unanalyzed one.
- function Num_An_Formals (F_Copy : List_Id) return Assoc_Count;
+ function Num_An_Formals (F_Copy : List_Id) return Assoc_Count;
-- Number of analyzed formals that correspond directly to unanalyzed
-- formals. There are all sorts of other things in F_Copy, which
-- are not counted.
- procedure Check_Box (I_Node, Actual : Node_Id);
+ procedure Check_Box (N, Actual : Node_Id);
-- Check for errors in "others => <>" and "Name => <>"
- function Default (Un_Formal : Node_Id) return Generic_Actual_Rec;
+ function Default (Un_Formal : Node_Id) return Actual_Rec;
-- Return the default for a given formal, which can be a name,
-- expression, box, etc.
procedure Match_Positional
- (Src_Assoc : in out Node_Id; Assoc : in out Assoc_Rec);
+ (Src_Assoc : in out Node_Id;
+ Assoc : in out Assoc_Rec);
-- Called by Match_Assocs to match one positional parameter association.
-- If the current formal (in Assoc) is not a use clause, then there is a
-- match, and we set Assoc.Actual and move Src_Assoc to the next one.
procedure Match_Named
- (Src_Assoc : Node_Id; Assoc : in out Assoc_Rec;
- Found : in out Boolean);
+ (Src_Assoc : Node_Id;
+ Assoc : in out Assoc_Rec;
+ Found : in out Boolean);
-- Called by Match_Assocs to match one named parameter association.
-- If the current formal (in Assoc) is not a use clause, and the
-- selector name matches the formal name, then there is a match,
@@ -1343,48 +1357,50 @@ package body Sem_Ch12 is
-- the matched formal, and set Found to True.
procedure Inference_Msg
- (Gen_Unit : Entity_Id;
- Inferred_To, Inferred_From : Assoc_Rec;
- Was_Inferred : Boolean);
+ (Gen_Unit : Entity_Id;
+ Inferred_To : Assoc_Rec;
+ Inferred_From : Assoc_Rec;
+ Was_Inferred : Boolean);
-- If Was_Inferred is True, this prints out an "info:" message
-- showing the inference.
-- If Was_Inferred is False, the message says that it could have
-- been inferred.
function Find_Assoc
- (Gen_Assocs : Gen_Assocs_Rec; F : Entity_Id) return Assoc_Index;
- -- Return the index of F in Gen_Assocs.Assocs, which must be
- -- present.
+ (Match : Match_Rec;
+ F : Entity_Id) return Assoc_Index;
+ -- Return the index of F in Match.Assocs, which must be present
procedure Maybe_Infer_One
- (Gen_Assocs : in out Gen_Assocs_Rec;
- FF, AA : N_Entity_Id; Inferred_From : Assoc_Index;
- Reason : Inference_Reason);
+ (Match : in out Match_Rec;
+ FF, AA : N_Entity_Id;
+ Inferred_From : Assoc_Index;
+ Reason : Inference_Reason);
-- If it makes sense to infer that formal FF is associated with
-- actual AA, then do so.
procedure Infer_From_Access
- (Gen_Assocs : in out Gen_Assocs_Rec;
- Index : Assoc_Index;
- F : Node_Id;
+ (Match : in out Match_Rec;
+ Index : Assoc_Index;
+ F : Node_Id;
A_Full : Entity_Id);
-- Try to infer the designated type
procedure Infer_From_Array
- (Gen_Assocs : in out Gen_Assocs_Rec;
- Index : Assoc_Index;
- F : Node_Id;
+ (Match : in out Match_Rec;
+ Index : Assoc_Index;
+ F : Node_Id;
A_Full : Entity_Id);
-- Try to infer the index and component types
procedure Infer_From_Discriminated
- (Gen_Assocs : in out Gen_Assocs_Rec;
- Index : Assoc_Index;
- F : Node_Id;
+ (Match : in out Match_Rec;
+ Index : Assoc_Index;
+ F : Node_Id;
A_Full : Entity_Id);
-- Try to infer the types of discriminants
- procedure Infer_Actuals (Gen_Assocs : in out Gen_Assocs_Rec);
+ procedure Infer_Actuals (Match : in out Match_Rec);
-- Called by Match_Assocs after processing explicit and defaulted
-- parameters to infer any that are still missing.
@@ -1542,13 +1558,13 @@ package body Sem_Ch12 is
-- Check_Box --
---------------
- procedure Check_Box (I_Node, Actual : Node_Id) is
+ procedure Check_Box (N, Actual : Node_Id) is
begin
-- "... => <>" is allowed only in formal packages, not old-fashioned
-- instantiations.
- if Nkind (I_Node) /= N_Formal_Package_Declaration
- and then Comes_From_Source (I_Node)
+ if Nkind (N) /= N_Formal_Package_Declaration
+ and then Comes_From_Source (N)
then
if Actual in N_Others_Choice_Id then
Error_Msg_N
@@ -1573,9 +1589,9 @@ package body Sem_Ch12 is
-- Default --
-------------
- function Default (Un_Formal : Node_Id) return Generic_Actual_Rec is
+ function Default (Un_Formal : Node_Id) return Actual_Rec is
begin
- return Result : Generic_Actual_Rec do
+ return Result : Actual_Rec do
case Nkind (Un_Formal) is
when N_Formal_Object_Declaration =>
if Present (Default_Expression (Un_Formal)) then
@@ -1727,22 +1743,24 @@ package body Sem_Ch12 is
------------------
function Match_Assocs
- (I_Node : Node_Id; Formals : List_Id; F_Copy : List_Id)
- return Gen_Assocs_Rec
+ (N : Node_Id;
+ Formals : List_Id;
+ F_Copy : List_Id) return Match_Rec
is
- Src_Assocs : constant List_Id := Generic_Associations (I_Node);
- Gen_Unit : constant Entity_Id := Defining_Entity (Parent (F_Copy));
+ Src_Assocs : constant List_Id := Generic_Associations (N);
+ Gen_Unit : constant Entity_Id := Defining_Entity (Parent (F_Copy));
+
begin
pragma Assert
(Num_An_Formals (F_Copy) = Num_Formals (Formals)
or else Serious_Errors_Detected > 0);
- return Result : Gen_Assocs_Rec (Num_Assocs => Num_Formals (Formals))
+ return Result : Match_Rec (Num_Assocs => Num_Formals (Formals))
do
Result.Gen_Unit := Gen_Unit;
Result.Others_Present := False;
- -- Loop through the unanalyzed formals:
+ -- Loop through the unanalyzed formals
declare
procedure Set_Formal (F : Node_Id; Index : Assoc_Index);
@@ -1779,7 +1797,7 @@ package body Sem_Ch12 is
Iter (Formals);
end;
- -- Loop through the analyzed copy of the formals:
+ -- Loop through the analyzed copy of the formals
declare
procedure Set_An_Formal (F : Node_Id; Index : Assoc_Index);
@@ -1836,7 +1854,7 @@ package body Sem_Ch12 is
Iter (F_Copy);
end;
- -- Loop through actual source associations:
+ -- Loop through actual source associations
declare
Src_Assoc : Node_Id := First (Src_Assocs);
@@ -1864,7 +1882,7 @@ package body Sem_Ch12 is
-- Loop through named actuals and "others => <>":
while Present (Src_Assoc) loop
- Check_Box (I_Node, Src_Assoc);
+ Check_Box (N, Src_Assoc);
if Src_Assoc in N_Others_Choice_Id then
Result.Others_Present := True;
exit;
@@ -1942,8 +1960,8 @@ package body Sem_Ch12 is
end;
end loop;
- if Nkind (I_Node) /= N_Formal_Package_Declaration then
- Infer_Actuals (Gen_Assocs => Result);
+ if Nkind (N) /= N_Formal_Package_Declaration then
+ Infer_Actuals (Result);
end if;
-- Check for missing actuals
@@ -1969,9 +1987,10 @@ package body Sem_Ch12 is
-------------------
procedure Inference_Msg
- (Gen_Unit : Entity_Id;
- Inferred_To, Inferred_From : Assoc_Rec;
- Was_Inferred : Boolean)
+ (Gen_Unit : Entity_Id;
+ Inferred_To : Assoc_Rec;
+ Inferred_From : Assoc_Rec;
+ Was_Inferred : Boolean)
is
pragma Assert (Debug_Flag_Underscore_II); -- This is only for -gnatd_I
@@ -2009,7 +2028,8 @@ package body Sem_Ch12 is
------------------------------
procedure Note_Potential_Inference
- (I_Node : Node_Id; Gen_Assocs : Gen_Assocs_Rec)
+ (N : Node_Id;
+ Match : Match_Rec)
is
begin
if not Debug_Flag_Underscore_II or else Serious_Errors_Detected > 0
@@ -2017,20 +2037,21 @@ package body Sem_Ch12 is
return;
end if;
- for Index in Gen_Assocs.Assocs'Range loop
+ for Index in Match.Assocs'Range loop
declare
- Assoc : Assoc_Rec renames Gen_Assocs.Assocs (Index);
+ Assoc : Assoc_Rec renames Match.Assocs (Index);
+
begin
if Assoc.Actual_Origin = From_Explicit_Actual
and then Present (Assoc.Info_Inferred_Actual)
- and then In_Extended_Main_Source_Unit (I_Node)
- and then not In_Internal_Unit (I_Node)
+ and then In_Extended_Main_Source_Unit (N)
+ and then not In_Internal_Unit (N)
then
Inference_Msg
- (Gen_Assocs.Gen_Unit,
- Inferred_To => Assoc,
- Inferred_From => Gen_Assocs.Assocs (Assoc.Inferred_From),
- Was_Inferred => False);
+ (Match.Gen_Unit,
+ Inferred_To => Assoc,
+ Inferred_From => Match.Assocs (Assoc.Inferred_From),
+ Was_Inferred => False);
end if;
end;
end loop;
@@ -2041,11 +2062,12 @@ package body Sem_Ch12 is
--------------
function Find_Assoc
- (Gen_Assocs : Gen_Assocs_Rec; F : Entity_Id) return Assoc_Index
+ (Match : Match_Rec;
+ F : Entity_Id) return Assoc_Index
is
begin
- for Index in Gen_Assocs.Assocs'Range loop
- if Defining_Entity (Gen_Assocs.Assocs (Index).An_Formal) = F then
+ for Index in Match.Assocs'Range loop
+ if Defining_Entity (Match.Assocs (Index).An_Formal) = F then
return Index;
end if;
end loop;
@@ -2058,13 +2080,14 @@ package body Sem_Ch12 is
---------------------
procedure Maybe_Infer_One
- (Gen_Assocs : in out Gen_Assocs_Rec;
- FF, AA : N_Entity_Id; Inferred_From : Assoc_Index;
- Reason : Inference_Reason)
+ (Match : in out Match_Rec;
+ FF, AA : N_Entity_Id;
+ Inferred_From : Assoc_Index;
+ Reason : Inference_Reason)
is
begin
if not (Is_Generic_Type (FF)
- and then Scope (FF) = Gen_Assocs.Gen_Unit)
+ and then Scope (FF) = Match.Gen_Unit)
then
return; -- no inference if not a formal type of this generic
end if;
@@ -2074,12 +2097,12 @@ package body Sem_Ch12 is
end if;
declare
- Index : constant Assoc_Index := Find_Assoc (Gen_Assocs, FF);
- Assoc : Assoc_Rec renames Gen_Assocs.Assocs (Index);
+ Index : constant Assoc_Index := Find_Assoc (Match, FF);
+ Assoc : Assoc_Rec renames Match.Assocs (Index);
pragma Assert (Defining_Entity (Assoc.An_Formal) = FF);
From_Actual : constant Node_Id :=
- Gen_Assocs.Assocs (Inferred_From).Actual.Name_Exp;
+ Match.Assocs (Inferred_From).Actual.Name_Exp;
begin
Assoc.Info_Inferred_Actual := AA;
@@ -2097,23 +2120,23 @@ package body Sem_Ch12 is
if Debug_Flag_Underscore_II then
Inference_Msg
- (Gen_Assocs.Gen_Unit,
- Inferred_To => Assoc,
- Inferred_From => Gen_Assocs.Assocs (Assoc.Inferred_From),
- Was_Inferred => True);
+ (Match.Gen_Unit,
+ Inferred_To => Assoc,
+ Inferred_From => Match.Assocs (Assoc.Inferred_From),
+ Was_Inferred => True);
end if;
end if;
end;
end Maybe_Infer_One;
- -------------------
- -- Infer_Actuals --
- -------------------
+ -----------------------
+ -- Infer_From_Access --
+ -----------------------
procedure Infer_From_Access
- (Gen_Assocs : in out Gen_Assocs_Rec;
- Index : Assoc_Index;
- F : Node_Id;
+ (Match : in out Match_Rec;
+ Index : Assoc_Index;
+ F : Node_Id;
A_Full : Entity_Id)
is
begin
@@ -2124,7 +2147,7 @@ package body Sem_Ch12 is
AA : constant Entity_Id := Designated_Type (A_Full);
begin
Maybe_Infer_One
- (Gen_Assocs,
+ (Match,
FF,
AA,
Inferred_From => Index,
@@ -2133,10 +2156,14 @@ package body Sem_Ch12 is
end if;
end Infer_From_Access;
+ ----------------------
+ -- Infer_From_Array --
+ ----------------------
+
procedure Infer_From_Array
- (Gen_Assocs : in out Gen_Assocs_Rec;
- Index : Assoc_Index;
- F : Node_Id;
+ (Match : in out Match_Rec;
+ Index : Assoc_Index;
+ F : Node_Id;
A_Full : Entity_Id)
is
begin
@@ -2150,7 +2177,7 @@ package body Sem_Ch12 is
while Present (F_Index_Type) and then Present (A_Index_Type)
loop
Maybe_Infer_One
- (Gen_Assocs,
+ (Match,
Etype (F_Index_Type),
Etype (A_Index_Type),
Inferred_From => Index,
@@ -2168,7 +2195,7 @@ package body Sem_Ch12 is
Component_Type (A_Full);
begin
Maybe_Infer_One
- (Gen_Assocs,
+ (Match,
F_Comp_Type,
A_Comp_Type,
Inferred_From => Index,
@@ -2177,10 +2204,14 @@ package body Sem_Ch12 is
end if;
end Infer_From_Array;
+ ------------------------------
+ -- Infer_From_Discriminated --
+ ------------------------------
+
procedure Infer_From_Discriminated
- (Gen_Assocs : in out Gen_Assocs_Rec;
- Index : Assoc_Index;
- F : Node_Id;
+ (Match : in out Match_Rec;
+ Index : Assoc_Index;
+ F : Node_Id;
A_Full : Entity_Id)
is
begin
@@ -2196,7 +2227,7 @@ package body Sem_Ch12 is
begin
while Present (F_Discrim) loop
Maybe_Infer_One
- (Gen_Assocs,
+ (Match,
Etype (F_Discrim),
Etype (A_Discrim),
Inferred_From => Index,
@@ -2210,23 +2241,27 @@ package body Sem_Ch12 is
end if;
end Infer_From_Discriminated;
- procedure Infer_Actuals (Gen_Assocs : in out Gen_Assocs_Rec) is
- -- Note that we can infer FROM defaults, but we cannot infer TO a
- -- parameter that has a default. We can also infer from inferred
- -- types.
+ -------------------
+ -- Infer_Actuals --
+ -------------------
- -- We don't need to check that multiple inferences get the same
- -- answer; the second one will get a type mismatch or nonstatically
- -- matching error.
+ -- Note that we can infer FROM defaults, but we cannot infer TO a
+ -- parameter that has a default. We can also infer from inferred
+ -- types.
- -- This code needs to be robust, in the sense of tolerating illegal
- -- code, because we have not yet checked all legality rules. For
- -- example, if a formal type F has a discriminant whose type is
- -- another formal type, then we want to infer the type of the
- -- discriminant from the actual for F. That actual must have
- -- discriminants, but we have not checked that rule yet, so we
- -- need to tolerate an actual for F that has no discriminants.
+ -- We don't need to check that multiple inferences get the same
+ -- answer; the second one will get a type mismatch or nonstatically
+ -- matching error.
+ -- This code needs to be robust, in the sense of tolerating illegal
+ -- code, because we have not yet checked all legality rules. For
+ -- example, if a formal type F has a discriminant whose type is
+ -- another formal type, then we want to infer the type of the
+ -- discriminant from the actual for F. That actual must have
+ -- discriminants, but we have not checked that rule yet, so we
+ -- need to tolerate an actual for F that has no discriminants.
+
+ procedure Infer_Actuals (Match : in out Match_Rec) is
begin
-- For each parameter, check whether we can infer FROM that one TO
-- other ones.
@@ -2240,12 +2275,12 @@ package body Sem_Ch12 is
-- designated type. The reverse loop implies that we will see the
-- array type, then the access type, then the designated type.
- for Index in reverse Gen_Assocs.Assocs'Range loop -- NB: "reverse"
- if Gen_Assocs.Assocs (Index).Actual.Kind = Name_Exp then
+ for Index in reverse Match.Assocs'Range loop -- NB: "reverse"
+ if Match.Assocs (Index).Actual.Kind = Name_Exp then
declare
- F : constant Node_Id := Gen_Assocs.Assocs (Index).An_Formal;
+ F : constant Node_Id := Match.Assocs (Index).An_Formal;
A_E : constant Node_Id :=
- Gen_Assocs.Assocs (Index).Actual.Name_Exp;
+ Match.Assocs (Index).Actual.Name_Exp;
A_Full : Entity_Id := Empty;
begin
if Nkind (A_E) in N_Has_Entity then
@@ -2264,7 +2299,7 @@ package body Sem_Ch12 is
then
case Ekind (Defining_Entity (F)) is
when E_Access_Type | E_General_Access_Type =>
- Infer_From_Access (Gen_Assocs, Index, F, A_Full);
+ Infer_From_Access (Match, Index, F, A_Full);
when E_Access_Subtype
| E_Access_Attribute_Type
@@ -2274,7 +2309,7 @@ package body Sem_Ch12 is
raise Program_Error;
when E_Array_Type | E_Array_Subtype =>
- Infer_From_Array (Gen_Assocs, Index, F, A_Full);
+ Infer_From_Array (Match, Index, F, A_Full);
when E_String_Literal_Subtype =>
raise Program_Error;
@@ -2283,13 +2318,12 @@ package body Sem_Ch12 is
null;
end case;
- Infer_From_Discriminated (Gen_Assocs, Index, F, A_Full);
+ Infer_From_Discriminated (Match, Index, F, A_Full);
end if;
end;
end if;
end loop;
end Infer_Actuals;
-
end Associations;
---------------------------
@@ -2316,46 +2350,49 @@ package body Sem_Ch12 is
--------------------------
function Analyze_Associations
- (I_Node : Node_Id;
+ (N : Node_Id;
Formals : List_Id;
F_Copy : List_Id) return List_Id
is
use Associations;
- Result_Renamings : constant List_Id := New_List;
+ Actuals_To_Freeze : constant Elist_Id := New_Elmt_List;
+ Default_Actuals : constant List_Id := New_List;
+ Result_Renamings : constant List_Id := New_List;
-- To be returned. Includes "renamings" broadly interpreted
-- (e.g. subtypes are used for types).
- Actuals_To_Freeze : constant Elist_Id := New_Elmt_List;
- Default_Actuals : constant List_Id := New_List;
-
- Gen_Assocs : constant Gen_Assocs_Rec :=
- Match_Assocs (I_Node, Formals, F_Copy);
+ Match : constant Match_Rec := Match_Assocs (N, Formals, F_Copy);
begin
- for Matching_Actual_Index in Gen_Assocs.Assocs'Range loop
+ for Index in Match.Assocs'Range loop
declare
- Assoc : Assoc_Rec renames
- Gen_Assocs.Assocs (Matching_Actual_Index);
+ Assoc : Assoc_Rec renames Match.Assocs (Index);
+
begin
if Nkind (Assoc.Un_Formal) = N_Formal_Package_Declaration
and then Error_Posted (Assoc.An_Formal)
then
-- Restrict this to N_Formal_Package_Declaration,
-- because otherwise we miss errors.
+
Abandon_Instantiation (Instantiation_Node);
end if;
- if Nkind (Assoc.Un_Formal) in
- N_Use_Package_Clause | N_Use_Type_Clause
+ if Nkind (Assoc.Un_Formal) in N_Use_Package_Clause
+ | N_Use_Type_Clause
then
- -- Copy the use clause to where it belongs:
+ -- Copy the use clause to where it belongs
+
Append (New_Copy_Tree (Assoc.Un_Formal), Result_Renamings);
else
Analyze_One_Association
- (I_Node, Assoc,
- Result_Renamings, Default_Actuals, Actuals_To_Freeze);
+ (N,
+ Assoc,
+ Result_Renamings,
+ Default_Actuals,
+ Actuals_To_Freeze);
end if;
end;
end loop;
@@ -2366,9 +2403,10 @@ package body Sem_Ch12 is
declare
Elmt : Elmt_Id := First_Elmt (Actuals_To_Freeze);
+
begin
while Present (Elmt) loop
- Freeze_Before (I_Node, Node (Elmt));
+ Freeze_Before (N, Node (Elmt));
Next_Elmt (Elmt);
end loop;
end;
@@ -2388,17 +2426,17 @@ package body Sem_Ch12 is
Next (Default);
end loop;
- if No (Generic_Associations (I_Node)) then
- Set_Generic_Associations (I_Node, Default_Actuals);
+ if No (Generic_Associations (N)) then
+ Set_Generic_Associations (N, Default_Actuals);
else
- Append_List_To (Generic_Associations (I_Node), Default_Actuals);
+ Append_List_To (Generic_Associations (N), Default_Actuals);
end if;
end;
end if;
- Note_Potential_Inference (I_Node, Gen_Assocs);
+ Note_Potential_Inference (N, Match);
- Check_Fixed_Point_Warning (Gen_Assocs, Result_Renamings);
+ Check_Fixed_Point_Warning (Match, Result_Renamings);
return Result_Renamings;
end Analyze_Associations;
@@ -2408,9 +2446,8 @@ package body Sem_Ch12 is
-----------------------------
procedure Analyze_One_Association
- (I_Node : Node_Id;
- Assoc : Associations.Assoc_Rec;
- -- Logical 'in out' parameters:
+ (N : Node_Id;
+ Assoc : Associations.Assoc_Rec;
Result_Renamings : List_Id;
Default_Actuals : List_Id;
Actuals_To_Freeze : Elist_Id)
@@ -2482,11 +2519,11 @@ package body Sem_Ch12 is
if No (Match) and then not Inside_A_Generic then
Append_To (Default_Actuals,
- Make_Generic_Association (Sloc (I_Node),
+ Make_Generic_Association (Sloc (N),
Selector_Name =>
New_Occurrence_Of
(Defining_Identifier
- (Assoc.Un_Formal), Sloc (I_Node)),
+ (Assoc.Un_Formal), Sloc (N)),
Explicit_Generic_Actual_Parameter =>
New_Copy_Tree (Default_Expression (Assoc.Un_Formal))));
end if;
@@ -2607,7 +2644,7 @@ package body Sem_Ch12 is
-- unless this is a rewritten formal package, or the
-- formal is an Ada 2012 formal incomplete type.
- if Nkind (I_Node) = N_Formal_Package_Declaration
+ if Nkind (N) = N_Formal_Package_Declaration
or else
(Ada_Version >= Ada_2012
and then
@@ -2693,7 +2730,7 @@ package body Sem_Ch12 is
-- An instantiation is a freeze point for the actuals,
-- unless this is a rewritten formal package.
- if Nkind (I_Node) /= N_Formal_Package_Declaration
+ if Nkind (N) /= N_Formal_Package_Declaration
and then Nkind (Match) = N_Identifier
and then Is_Subprogram (Entity (Match))
@@ -2711,7 +2748,7 @@ package body Sem_Ch12 is
-- subprograms defined in Standard which are used
-- as generic actuals.
- and then In_Same_Code_Unit (Entity (Match), I_Node)
+ and then In_Same_Code_Unit (Entity (Match), N)
and then Has_Fully_Defined_Profile (Entity (Match))
then
-- Mark the subprogram as having a delayed freeze
@@ -2734,11 +2771,11 @@ package body Sem_Ch12 is
begin
Append_To (Default_Actuals,
- Make_Generic_Association (Sloc (I_Node),
+ Make_Generic_Association (Sloc (N),
Selector_Name =>
- New_Occurrence_Of (Subp, Sloc (I_Node)),
+ New_Occurrence_Of (Subp, Sloc (N)),
Explicit_Generic_Actual_Parameter =>
- New_Occurrence_Of (Subp, Sloc (I_Node))));
+ New_Occurrence_Of (Subp, Sloc (N))));
end;
end if;
@@ -2851,13 +2888,13 @@ package body Sem_Ch12 is
if not Expander_Active
or else not Has_Completion (Actual)
- or else not In_Same_Source_Unit (I_Node, Actual)
+ or else not In_Same_Source_Unit (N, Actual)
or else Is_Frozen (Actual)
or else
(Present (Renamed_Entity (Actual))
and then
not In_Same_Source_Unit
- (I_Node, (Renamed_Entity (Actual))))
+ (N, (Renamed_Entity (Actual))))
then
null;
@@ -2869,7 +2906,7 @@ package body Sem_Ch12 is
Needs_Freezing := True;
- P := Parent (I_Node);
+ P := Parent (N);
while Nkind (P) /= N_Compilation_Unit loop
if Nkind (P) = N_Handled_Sequence_Of_Statements
then
@@ -3586,7 +3623,7 @@ package body Sem_Ch12 is
Decls :=
Analyze_Associations
- (I_Node => Original_Node (N),
+ (N => Original_Node (N),
Formals => Generic_Formal_Declarations (Act_Tree),
F_Copy => Generic_Formal_Declarations (Gen_Decl));
@@ -3602,9 +3639,8 @@ package body Sem_Ch12 is
if No (Visible_Declarations (Specification (Pack_Decl))) then
Set_Visible_Declarations (Specification (Pack_Decl), Decls);
else
- Insert_List_Before
- (First (Visible_Declarations (Specification (Pack_Decl))),
- Decls);
+ Prepend_List_To
+ (Visible_Declarations (Specification (Pack_Decl)), Decls);
end if;
return Pack_Decl;
@@ -4860,11 +4896,10 @@ package body Sem_Ch12 is
-- Local declarations
- Gen_Id : constant Node_Id := Name (N);
- Inst_Id : constant Entity_Id := Defining_Entity (N);
- Is_Actual_Pack : constant Boolean := Is_Internal (Inst_Id);
- Loc : constant Source_Ptr := Sloc (N);
-
+ Gen_Id : constant Node_Id := Name (N);
+ Loc : constant Source_Ptr := Sloc (N);
+ Is_Abbrev : constant Boolean :=
+ Is_Abbreviated_Instance (Defining_Entity (N));
Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
Saved_ISMP : constant Boolean :=
@@ -4877,7 +4912,6 @@ package body Sem_Ch12 is
-- Save style check mode for restore on exit
Act_Decl : Node_Id;
- Act_Decl_Name : Node_Id;
Act_Decl_Id : Entity_Id;
Act_Spec : Node_Id;
Act_Tree : Node_Id;
@@ -4918,29 +4952,7 @@ package body Sem_Ch12 is
Instantiation_Node := N;
- -- Case of instantiation of a generic package
-
- if Nkind (N) = N_Package_Instantiation then
- Act_Decl_Id := New_Copy (Defining_Entity (N));
-
- if Nkind (Defining_Unit_Name (N)) = N_Defining_Program_Unit_Name then
- Act_Decl_Name :=
- Make_Defining_Program_Unit_Name (Loc,
- Name =>
- New_Copy_Tree (Name (Defining_Unit_Name (N))),
- Defining_Identifier => Act_Decl_Id);
- else
- Act_Decl_Name := Act_Decl_Id;
- end if;
-
- -- Case of instantiation of a formal package
-
- else
- Act_Decl_Id := Defining_Identifier (N);
- Act_Decl_Name := Act_Decl_Id;
- end if;
-
- Generate_Definition (Act_Decl_Id);
+ Act_Decl_Id := New_Copy (Defining_Entity (N));
Mutate_Ekind (Act_Decl_Id, E_Package);
Set_Is_Not_Self_Hidden (Act_Decl_Id);
@@ -4972,7 +4984,7 @@ package body Sem_Ch12 is
-- Except for an abbreviated instance created to check a formal package,
-- install the parent if this is a generic child unit.
- if not Is_Abbreviated_Instance (Inst_Id) then
+ if not Is_Abbrev then
Check_Generic_Child_Unit (Gen_Id, Parent_Installed);
end if;
@@ -5075,9 +5087,6 @@ package body Sem_Ch12 is
goto Leave;
else
- Mutate_Ekind (Inst_Id, E_Package);
- Set_Scope (Inst_Id, Current_Scope);
-
-- If the context of the instance is subject to SPARK_Mode "off" or
-- the annotation is altogether missing, set the global flag which
-- signals Analyze_Pragma to ignore all SPARK_Mode pragmas within
@@ -5115,22 +5124,38 @@ package body Sem_Ch12 is
-- If this is the instance created to validate an actual package,
-- only the formals matter, do not examine the package spec itself.
- if Is_Actual_Pack then
+ if Is_Abbrev then
Set_Visible_Declarations (Act_Spec, New_List);
Set_Private_Declarations (Act_Spec, New_List);
end if;
Renamings :=
Analyze_Associations
- (I_Node => N,
+ (N => N,
Formals => Generic_Formal_Declarations (Act_Tree),
F_Copy => Generic_Formal_Declarations (Gen_Decl));
Vis_Prims_List := Check_Hidden_Primitives (Renamings);
+ -- Set minimal decoration on the original entity
+
+ Mutate_Ekind (Defining_Entity (N), E_Package);
+ Set_Scope (Defining_Entity (N), Current_Scope);
+
Set_Instance_Env (Gen_Unit, Act_Decl_Id);
- Set_Defining_Unit_Name (Act_Spec, Act_Decl_Name);
Set_Is_Generic_Instance (Act_Decl_Id);
+ Generate_Definition (Act_Decl_Id);
+
+ if Nkind (Defining_Unit_Name (N)) = N_Defining_Program_Unit_Name then
+ Set_Defining_Unit_Name (Act_Spec,
+ Make_Defining_Program_Unit_Name (Loc,
+ Name =>
+ New_Copy_Tree (Name (Defining_Unit_Name (N))),
+ Defining_Identifier => Act_Decl_Id));
+ else
+ Set_Defining_Unit_Name (Act_Spec, Act_Decl_Id);
+ end if;
+
Set_Generic_Parent (Act_Spec, Gen_Unit);
-- References to the generic in its own declaration or its body are
@@ -5274,7 +5299,7 @@ package body Sem_Ch12 is
and then (not Is_Child_Unit (Gen_Unit)
or else not Is_Generic_Unit (Scope (Gen_Unit)))
and then Might_Inline_Subp (Gen_Unit)
- and then not Is_Actual_Pack
+ and then not Is_Abbrev
then
if not Back_End_Inlining
and then (Front_End_Inlining or else Has_Inline_Always)
@@ -5319,7 +5344,7 @@ package body Sem_Ch12 is
or else Enclosing_Body_Present
or else Present (Corresponding_Body (Gen_Decl)))
and then Needs_Body_Instantiated (Gen_Unit)
- and then not Is_Actual_Pack
+ and then not Is_Abbrev
and then not Inline_Now
and then (Operating_Mode = Generate_Code
or else (Operating_Mode = Check_Semantics
@@ -6455,7 +6480,7 @@ package body Sem_Ch12 is
Renamings :=
Analyze_Associations
- (I_Node => N,
+ (N => N,
Formals => Generic_Formal_Declarations (Act_Tree),
F_Copy => Generic_Formal_Declarations (Gen_Decl));
@@ -7563,14 +7588,15 @@ package body Sem_Ch12 is
-------------------------------
procedure Check_Fixed_Point_Warning
- (Gen_Assocs : Associations.Gen_Assocs_Rec;
+ (Match : Associations.Match_Rec;
Renamings : List_Id)
is
use Associations;
+
begin
- for Type_Index in Gen_Assocs.Assocs'Range loop
+ for Type_Index in Match.Assocs'Range loop
declare
- Assoc : Assoc_Rec renames Gen_Assocs.Assocs (Type_Index);
+ Assoc : Assoc_Rec renames Match.Assocs (Type_Index);
begin
if Nkind (Assoc.An_Formal) = N_Formal_Type_Declaration
and then Is_Fixed_Point_Type (Defining_Entity (Assoc.An_Formal))
@@ -7599,9 +7625,9 @@ package body Sem_Ch12 is
Op := Alias (Node (Elem));
for Op_Index in Type_Index + 1 ..
- Gen_Assocs.Assocs'Last
+ Match.Assocs'Last
loop
- Formal := Gen_Assocs.Assocs (Op_Index).Un_Formal;
+ Formal := Match.Assocs (Op_Index).Un_Formal;
if Nkind (Formal) =
N_Formal_Concrete_Subprogram_Declaration
@@ -10058,13 +10084,12 @@ package body Sem_Ch12 is
-- the freeze node for Inst must be inserted after that of
-- Parent_Inst. This relation is established by comparing
-- the Slocs of Parent_Inst freeze node and Inst.
- -- We examine the parents of the enclosing lists to handle
+ -- We examine the parents (of the enclosing lists) to handle
-- the case where the parent instance is in the visible part
-- of a package declaration, and the inner instance is in
-- the corresponding private part.
- if Parent (List_Containing (Freeze_Node (Par_Id)))
- = Parent (List_Containing (N))
+ if Parent (Freeze_Node (Par_Id)) = Parent (N)
and then Sloc (Freeze_Node (Par_Id)) <= Sloc (N)
then
Insert_Freeze_Node_For_Instance (N, F_Node);
@@ -10383,7 +10408,8 @@ package body Sem_Ch12 is
-- investigated, and would allow this function to be significantly
-- simplified. ???
- Inst := Package_Instantiation (A);
+ Inst :=
+ (if Ekind (A) = E_Package then Package_Instantiation (A) else Empty);
if Present (Inst) then
if Nkind (Inst) = N_Package_Instantiation then
@@ -10430,10 +10456,11 @@ package body Sem_Ch12 is
else
Inst := Next (Decl);
- while Nkind (Inst) not in N_Formal_Package_Declaration
- | N_Function_Instantiation
- | N_Package_Instantiation
- | N_Procedure_Instantiation
+ while Present (Inst)
+ and then Nkind (Inst) not in N_Formal_Package_Declaration
+ | N_Function_Instantiation
+ | N_Package_Instantiation
+ | N_Procedure_Instantiation
loop
Next (Inst);
end loop;
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 75901bb..425d624 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -3713,8 +3713,8 @@ package body Sem_Ch3 is
Set_Is_Static_Expression (E, True);
Set_Etype (E, Universal_Integer);
- Set_Etype (Id, Universal_Integer);
Mutate_Ekind (Id, E_Named_Integer);
+ Set_Etype (Id, Universal_Integer);
Set_Is_Frozen (Id, True);
Set_Debug_Info_Needed (Id);
@@ -3774,8 +3774,8 @@ package body Sem_Ch3 is
if Is_Integer_Type (T) then
Resolve (E, T);
- Set_Etype (Id, Universal_Integer);
Mutate_Ekind (Id, E_Named_Integer);
+ Set_Etype (Id, Universal_Integer);
elsif Is_Real_Type (T) then
@@ -3806,15 +3806,15 @@ package body Sem_Ch3 is
end if;
Resolve (E, T);
- Set_Etype (Id, Universal_Real);
Mutate_Ekind (Id, E_Named_Real);
+ Set_Etype (Id, Universal_Real);
else
Wrong_Type (E, Any_Numeric);
Resolve (E, T);
- Set_Etype (Id, T);
Mutate_Ekind (Id, E_Constant);
+ Set_Etype (Id, T);
Set_Never_Set_In_Source (Id, True);
Set_Is_True_Constant (Id, True);
return;
@@ -3963,7 +3963,7 @@ package body Sem_Ch3 is
Data_Path_String : constant String :=
Absolute_Dir
& System.OS_Lib.Directory_Separator
- & Stringt.To_String (Strval (Def));
+ & S;
begin
Data_Path := Name_Find (Data_Path_String);
@@ -6468,12 +6468,15 @@ package body Sem_Ch3 is
Priv : Entity_Id;
Related_Id : Entity_Id;
Has_FLB_Index : Boolean := False;
+ K : Entity_Kind;
begin
if Nkind (Def) = N_Constrained_Array_Definition then
Index := First (Discrete_Subtype_Definitions (Def));
+ K := E_Array_Subtype;
else
Index := First (Subtype_Marks (Def));
+ K := E_Array_Type;
end if;
-- Find proper names for the implicit types which may be public. In case
@@ -6652,7 +6655,7 @@ package body Sem_Ch3 is
-- them unique suffixes, because GNATprove require distinct types to
-- have different names.
- T := Create_Itype (E_Void, P, Related_Id, 'T', Suffix_Index => -1);
+ T := Create_Itype (K, P, Related_Id, 'T', Suffix_Index => -1);
end if;
-- Constrained array case
@@ -8133,9 +8136,6 @@ package body Sem_Ch3 is
Set_Non_Binary_Modulus
(Implicit_Base, Non_Binary_Modulus (Parent_Base));
- Set_Is_Known_Valid
- (Implicit_Base, Is_Known_Valid (Parent_Base));
-
elsif Is_Floating_Point_Type (Parent_Type) then
-- Digits of base type is always copied from the digits value of
@@ -8508,11 +8508,19 @@ package body Sem_Ch3 is
Analyze (Decl);
- pragma Assert (Has_Discriminants (Full_Der)
- and then not Has_Unknown_Discriminants (Full_Der));
+ pragma
+ Assert
+ ((Has_Discriminants (Full_Der)
+ and then not Has_Unknown_Discriminants (Full_Der))
+ or else Serious_Errors_Detected > 0);
Uninstall_Declarations (Par_Scope);
+ if Etype (Full_Der) = Any_Type then
+ pragma Assert (Serious_Errors_Detected > 0);
+ return;
+ end if;
+
-- Freeze the underlying record view, to prevent generation of
-- useless dispatching information, which is simply shared with
-- the real derived type.
@@ -9477,8 +9485,8 @@ package body Sem_Ch3 is
if Constraint_Present then
if not Has_Discriminants (Parent_Base)
or else
- (Has_Unknown_Discriminants (Parent_Base)
- and then Is_Private_Type (Parent_Base))
+ (Has_Unknown_Discriminants (Parent_Type)
+ and then Is_Private_Type (Parent_Type))
then
Error_Msg_N
("invalid constraint: type has no discriminant",
@@ -15218,17 +15226,24 @@ package body Sem_Ch3 is
R : Node_Id := Empty;
T : constant Entity_Id := Etype (Index);
Is_FLB_Index : Boolean := False;
+ Is_Range : constant Boolean :=
+ Nkind (S) = N_Range
+ or else (Nkind (S) = N_Attribute_Reference
+ and then Attribute_Name (S) = Name_Range);
+ Is_Indic : constant Boolean := Nkind (S) = N_Subtype_Indication;
+ K : constant Entity_Kind :=
+ (if Is_Modular_Integer_Type (T) then E_Modular_Integer_Subtype
+ elsif Is_Integer_Type (T) then E_Signed_Integer_Subtype
+ else E_Enumeration_Subtype);
begin
- Def_Id :=
- Create_Itype (E_Void, Related_Nod, Related_Id, Suffix, Suffix_Index);
- Set_Etype (Def_Id, Base_Type (T));
+ if Is_Range or else Is_Indic then
+ Def_Id :=
+ Create_Itype (K, Related_Nod, Related_Id, Suffix, Suffix_Index);
+ Set_Etype (Def_Id, Base_Type (T));
+ end if;
- if Nkind (S) = N_Range
- or else
- (Nkind (S) = N_Attribute_Reference
- and then Attribute_Name (S) = Name_Range)
- then
+ if Is_Range then
-- A Range attribute will be transformed into N_Range by Resolve
-- If a range has an Empty upper bound, then remember that for later
@@ -15263,7 +15278,7 @@ package body Sem_Ch3 is
end if;
end if;
- elsif Nkind (S) = N_Subtype_Indication then
+ elsif Is_Indic then
-- The parser has verified that this is a discrete indication
@@ -15318,27 +15333,19 @@ package body Sem_Ch3 is
S, Entity (S));
end if;
- return;
-
else
Error_Msg_N ("invalid index constraint", S);
Rewrite (S, New_Occurrence_Of (T, Sloc (S)));
- return;
end if;
+
+ return;
end if;
-- Complete construction of the Itype
- if Is_Modular_Integer_Type (T) then
- Mutate_Ekind (Def_Id, E_Modular_Integer_Subtype);
-
- elsif Is_Integer_Type (T) then
- Mutate_Ekind (Def_Id, E_Signed_Integer_Subtype);
-
- else
- Mutate_Ekind (Def_Id, E_Enumeration_Subtype);
+ if K = E_Enumeration_Subtype then
Set_Is_Character_Type (Def_Id, Is_Character_Type (T));
- Set_First_Literal (Def_Id, First_Literal (T));
+ Set_First_Literal (Def_Id, First_Literal (T));
end if;
Set_Size_Info (Def_Id, (T));
@@ -20603,17 +20610,17 @@ package body Sem_Ch3 is
if No (Def_Id) then
Def_Id :=
- Create_Itype (E_Void, Related_Nod, Related_Id, 'D', Suffix_Index);
+ Create_Itype
+ ((if Is_Signed_Integer_Type (T) then E_Signed_Integer_Subtype
+ elsif Is_Modular_Integer_Type (T) then E_Modular_Integer_Subtype
+ else E_Enumeration_Subtype),
+ Related_Nod,
+ Related_Id,
+ 'D',
+ Suffix_Index);
Set_Etype (Def_Id, Base_Type (T));
- if Is_Signed_Integer_Type (T) then
- Mutate_Ekind (Def_Id, E_Signed_Integer_Subtype);
-
- elsif Is_Modular_Integer_Type (T) then
- Mutate_Ekind (Def_Id, E_Modular_Integer_Subtype);
-
- else
- Mutate_Ekind (Def_Id, E_Enumeration_Subtype);
+ if Ekind (Def_Id) = E_Enumeration_Subtype then
Set_Is_Character_Type (Def_Id, Is_Character_Type (T));
Set_First_Literal (Def_Id, First_Literal (T));
end if;
@@ -21247,6 +21254,12 @@ package body Sem_Ch3 is
Discr := First (Discriminant_Specifications (N));
while Present (Discr) loop
+ if Ekind (Defining_Identifier (Discr)) = E_In_Parameter then
+ Reinit_Field_To_Zero
+ (Defining_Identifier (Discr), F_Discriminal_Link);
+ end if;
+
+ Mutate_Ekind (Defining_Identifier (Discr), E_Discriminant);
Enter_Name (Defining_Identifier (Discr));
-- For navigation purposes we add a reference to the discriminant
@@ -21522,11 +21535,6 @@ package body Sem_Ch3 is
while Present (Discr) loop
Id := Defining_Identifier (Discr);
- if Ekind (Id) = E_In_Parameter then
- Reinit_Field_To_Zero (Id, F_Discriminal_Link);
- end if;
-
- Mutate_Ekind (Id, E_Discriminant);
Set_Is_Not_Self_Hidden (Id);
Reinit_Component_Location (Id);
Reinit_Esize (Id);
diff --git a/gcc/ada/sem_ch8.ads b/gcc/ada/sem_ch8.ads
index 70fbcf2..f915f2c 100644
--- a/gcc/ada/sem_ch8.ads
+++ b/gcc/ada/sem_ch8.ads
@@ -100,11 +100,6 @@ package Sem_Ch8 is
-- entries in the current scope, and that will give all homonyms that are
-- declared before the point of call in the current scope. This is useful
-- for example in the processing for pragma Inline.
- --
- -- Flag Errors_OK should be set when error diagnostics are desired. Flag
- -- Marker_OK should be set when a N_Variable_Reference_Marker needs to be
- -- generated for a SPARK object in order to detect elaboration issues. Flag
- -- Reference_OK should be set when N must generate a cross reference.
procedure Find_Selected_Component (N : Node_Id);
-- Resolve various cases of selected components, recognize expanded names
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 3c80d23..679d0ee 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -333,7 +333,7 @@ package body Sem_Util is
-- Add_Global_Declaration --
----------------------------
- procedure Add_Global_Declaration (N : Node_Id) is
+ procedure Add_Global_Declaration (Decl : Node_Id) is
Aux_Node : constant Node_Id := Aux_Decls_Node (Cunit (Current_Sem_Unit));
begin
@@ -341,8 +341,8 @@ package body Sem_Util is
Set_Declarations (Aux_Node, New_List);
end if;
- Append_To (Declarations (Aux_Node), N);
- Analyze (N);
+ Append_To (Declarations (Aux_Node), Decl);
+ Analyze (Decl);
end Add_Global_Declaration;
--------------------------------
@@ -8026,6 +8026,7 @@ package body Sem_Util is
-- but the error should be posted on it, not on the component.
elsif Ekind (E) = E_Discriminant
+ and then Is_Not_Self_Hidden (E)
and then Present (Scope (Def_Id))
and then Scope (Def_Id) /= Current_Scope
then
@@ -8051,7 +8052,10 @@ package body Sem_Util is
-- Avoid cascaded messages with duplicate components in
-- derived types.
- if Ekind (E) in E_Component | E_Discriminant then
+ if Ekind (E) = E_Component
+ or else (Ekind (E) = E_Discriminant
+ and then Is_Not_Self_Hidden (E))
+ then
return;
end if;
end if;
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 0e97806..8d5bda0 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -54,12 +54,12 @@ package Sem_Util is
-- Add A to the list of access types to process when expanding the
-- freeze node of E.
- procedure Add_Global_Declaration (N : Node_Id);
- -- These procedures adds a declaration N at the library level, to be
+ procedure Add_Global_Declaration (Decl : Node_Id);
+ -- This procedure adds a declaration Decl at the library level, to be
-- elaborated before any other code in the unit. It is used for example
-- for the entity that marks whether a unit has been elaborated. The
-- declaration is added to the Declarations list of the Aux_Decls_Node
- -- for the current unit. The declarations are added in the current scope,
+ -- for the current unit. The declared entity is added to current scope,
-- so the caller should push a new scope as required before the call.
function Add_Suffix (E : Entity_Id; Suffix : Character) return Name_Id;
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 1bc97a8..74f9fe3 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1712,17 +1712,11 @@ package body Sem_Warn is
and then Ekind (E1) /= E_Class_Wide_Type
- -- Objects other than parameters of task types are allowed to
- -- be non-referenced, since they start up tasks.
+ -- Objects that are not parameters and whose types have tasks
+ -- are allowed to be non-referenced since they start up tasks.
- and then ((Ekind (E1) /= E_Variable
- and then Ekind (E1) /= E_Constant
- and then Ekind (E1) /= E_Component)
-
- -- Check that E1T is not a task or a composite type
- -- with a task component.
-
- or else not Has_Task (E1T))
+ and then not (Ekind (E1) in E_Variable | E_Constant | E_Component
+ and then Has_Task (E1T))
-- For subunits, only place warnings on the main unit itself,
-- since parent units are not completely compiled.
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index a0c7314..9b5d3c2 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -8172,7 +8172,7 @@ package Sinfo is
-- An implicit label declaration is created for every occurrence of a
-- label on a statement or a label on a block or loop. It is chained
-- in the declarations of the innermost enclosing block as specified
- -- in RM section 5.1 (3).
+ -- in RM section 5.1 (12).
-- The Defining_Identifier is the actual identifier for the statement
-- identifier. Note that the occurrence of the label is a reference, NOT
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index 1e54340..efad12c 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -1220,17 +1220,20 @@ package body Switch.C is
List_Representation_Info :=
Character'Pos (C) - Character'Pos ('0');
- when 's' =>
- List_Representation_Info_To_File := True;
+ when 'e' =>
+ List_Representation_Info_Extended := True;
- when 'j' =>
- List_Representation_Info_To_JSON := True;
+ when 'h' =>
+ List_Representation_Info_Holes := True;
when 'm' =>
List_Representation_Info_Mechanisms := True;
- when 'e' =>
- List_Representation_Info_Extended := True;
+ when 'j' =>
+ List_Representation_Info_To_JSON := True;
+
+ when 's' =>
+ List_Representation_Info_To_File := True;
when others =>
Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
@@ -1245,6 +1248,12 @@ package body Switch.C is
Osint.Fail ("-gnatRe is incompatible with -gnatRj");
end if;
+ if List_Representation_Info_To_JSON
+ and then List_Representation_Info_Holes
+ then
+ Osint.Fail ("-gnatRh is incompatible with -gnatRj");
+ end if;
+
-- -gnats (syntax check only)
when 's' =>
diff --git a/gcc/ada/switch.adb b/gcc/ada/switch.adb
index b1abe1e..691abc0 100644
--- a/gcc/ada/switch.adb
+++ b/gcc/ada/switch.adb
@@ -93,7 +93,7 @@ package body Switch is
Set_Standard_Output;
Usage;
Write_Eol;
- Write_Line ("Report bugs to report@adacore.com");
+ Write_Line ("Report bugs to support@adacore.com");
Exit_Program (E_Success);
end if;
end Check_Version_And_Help_G;
diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb
index b1a2c34..16e2bc8 100644
--- a/gcc/ada/treepr.adb
+++ b/gcc/ada/treepr.adb
@@ -87,7 +87,7 @@ package body Treepr is
procedure Destroy (Value : in out Nat) is null;
pragma Annotate (CodePeer, False_Positive, "unassigned parameter",
"in out parameter is required to instantiate generic");
- -- Dummy routine for destroing hashed values
+ -- Dummy routine for destroying hashed values
package Serial_Numbers is new Dynamic_Hash_Tables
(Key_Type => Int,
diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb
index efa38b5..5b87bb5 100644
--- a/gcc/ada/usage.adb
+++ b/gcc/ada/usage.adb
@@ -92,17 +92,17 @@ begin
-- Common switches available everywhere
- Write_Switch_Char ("g ", "");
+ Write_Switch_Char ("g ", "");
Write_Line ("Generate debugging information");
- Write_Switch_Char ("Idir ", "");
+ Write_Switch_Char ("Idir ", "");
Write_Line ("Specify source files search path");
- Write_Switch_Char ("I- ", "");
+ Write_Switch_Char ("I- ", "");
Write_Line ("Do not look for sources in current directory");
- Write_Switch_Char ("O[0123] ", "");
- Write_Line ("Control the optimization level");
+ Write_Switch_Char ("O[?] ", "");
+ Write_Line ("Control the optimization level (?=0/1/2/3/s/z/g)");
Write_Eol;
@@ -402,7 +402,7 @@ begin
Write_Switch_Char ("R?");
Write_Line
- ("List rep info (?=0/1/2/3/4/e/m for none/types/all/sym/cg/ext/mech)");
+ ("List rep info (?=1/2/3/4/e/h/m for types/all/sym/cg/ext/holes/mech)");
Write_Switch_Char ("R?j");
Write_Line ("List rep info in the JSON data interchange format");
Write_Switch_Char ("R?s");
diff --git a/gcc/ada/vast.adb b/gcc/ada/vast.adb
index acb48b6..59470fd 100644
--- a/gcc/ada/vast.adb
+++ b/gcc/ada/vast.adb
@@ -29,58 +29,285 @@ pragma Assertion_Policy (Check);
-- we want to run VAST with a compiler built without checks. Anyway, it's
-- harmless, because VAST is not run by default.
-with Atree; use Atree;
+with Ada.Unchecked_Deallocation;
+
+with System.Case_Util;
+
+with Atree; use Atree;
with Debug;
-with Debug_A; use Debug_A;
-with Lib; use Lib;
-with Namet; use Namet;
-with Output; use Output;
-with Opt; use Opt;
-with Sinfo.Nodes; use Sinfo.Nodes;
with Einfo.Entities; use Einfo.Entities;
-with Types; use Types;
+with Lib; use Lib;
+with Namet; use Namet;
+with Nlists; use Nlists;
+with Opt; use Opt;
+with Output;
+with Sinfo.Nodes; use Sinfo.Nodes;
+with Sinput;
+with Table;
+with Types; use Types;
package body VAST is
+ -- ???Basic tree properties not yet checked:
+ -- - No dangling trees. Every node that is reachable at all is reachable
+ -- by some syntactic path.
+ -- - Basic properties of Nlists/Elists (next/prev pointers make sense,
+ -- for example).
+
Force_Enable_VAST : constant Boolean := False;
-- Normally, VAST is enabled by the the -gnatd_V switch.
-- To force it to be enabled independent of any switches,
- -- change the above to True.
- Print_Disabled_Failing_Checks : constant Boolean := True;
- -- False means disabled checks are silent; True means we print a message
- -- (but still don't raise VAST_Failure).
-
- type Check_Enum is (Check_Other, Check_Error_Nodes);
- Enabled_Checks : constant array (Check_Enum) of Boolean :=
- (Check_Other => True,
--- others => False);
- others => True);
- -- Passing checks are Check_Other, which should always be enabled.
+ -- set this to True.
+
+ type Check_Enum is
+ (Check_Other,
+ Check_Sloc,
+ Check_Analyzed,
+ Check_Error_Nodes,
+ Check_Sharing,
+ Check_Parent_Present,
+ Check_Parent_Correct);
+
+ type Check_Status is
+ -- Action in case of check failure:
+ (Disabled, -- Do nothing
+ Enabled, -- Print messages, and raise an exception
+ Print_And_Continue); -- Print a message
+
+ pragma Warnings (Off, "Status*could be declared constant");
+ Status : array (Check_Enum) of Check_Status :=
+ (Check_Other => Enabled,
+ Check_Sloc => Disabled,
+ Check_Analyzed => Disabled,
+ Check_Error_Nodes => Print_And_Continue,
+ Check_Sharing => Disabled,
+ Check_Parent_Present => Print_And_Continue,
+ Check_Parent_Correct => Disabled);
+-- others => Print_And_Continue);
+-- others => Enabled);
+-- others => Disabled);
+ -- Passing checks are Check_Other, which should always be Enabled.
-- Currently-failing checks are different enumerals in Check_Enum,
-- which can be disabled individually until we fix the bugs, or enabled
-- when debugging particular bugs. Pass a nondefault Check_Enum to
-- Assert in order to deal with bugs we have not yet fixed,
- -- and play around with the value of Enabled_Checks above
- -- for testing and debugging.
+ -- and play around with the value of Status above for
+ -- testing and debugging.
--
-- Note: Once a bug is fixed, and the check passes reliably, we may choose
-- to remove that check from Check_Enum and use Check_Other instead.
+ type Node_Stack_Index is new Pos;
+ subtype Node_Stack_Count is
+ Node_Stack_Index'Base range 0 .. Node_Stack_Index'Last;
+
+ package Node_Stack is new Table.Table
+ (Table_Component_Type => Node_Id,
+ Table_Index_Type => Node_Stack_Index'Base,
+ Table_Low_Bound => 1,
+ Table_Initial => 1,
+ Table_Increment => 100,
+ Table_Name => "Node_Stack");
+
procedure Assert
(Condition : Boolean;
Check : Check_Enum := Check_Other;
Detail : String := "");
- -- Check that the Condition is True, and raise an exception otherwise.
- -- Check enables/disables the checking, according to Enabled_Checks above,
- -- and is printed on failure. Detail is an additional error message,
- -- also printed on failure.
-
- function Do_Node (N : Node_Id) return Traverse_Result;
- procedure Traverse is new Traverse_Proc (Do_Node);
+ -- Check that the Condition is True. Status determines action on failure.
+
+ function To_Mixed (A : String) return String;
+ -- Copied from System.Case_Util; old versions of that package do not have
+ -- this function, so this is needed for bootstrapping.
+
+ function Image (Kind : Node_Kind) return String is (To_Mixed (Kind'Img));
+ function Image (Kind : Entity_Kind) return String is (To_Mixed (Kind'Img));
+
+ procedure Put (S : String);
+ procedure Put_Line (S : String);
+ procedure Put_Node (N : Node_Id);
+ procedure Put_Node_Stack;
+ -- Output routines; print only if -gnatd_W (VAST in verbose mode) is
+ -- enabled.
+
+ procedure Put_Indentation;
+ -- Print spaces to indicate nesting depth of Node_Stack
+
+ procedure Enter_Node (N : Node_Id);
+ procedure Leave_Node (N : Node_Id);
+ -- Called for each node while walking the tree.
+ -- Push/pop N to/from Node_Stack.
+ -- Print enter/leave debugging messages.
+ -- ???Possible improvements to messages:
+ -- Walk subtrees in a better order.
+ -- Print field names.
+ -- Don't print boring fields (such as N_Empty nodes).
+ -- Print more info (value of literals, "A.B.C" for expanded names, etc.).
+ -- Share some code with Treepr.
+
+ procedure Do_Tree (N : Node_Id);
-- Do VAST checking on a tree of nodes
+ function Has_Subtrees (N : Node_Id) return Boolean;
+ -- True if N has one or more syntactic fields
+
+ procedure Do_Subtrees (N : Node_Id);
+ -- Call Do_Tree on all the subtrees (i.e. syntactic fields) of N
+
+ procedure Do_List (L : List_Id);
+ -- Call Do_Tree on the list elements
+
procedure Do_Unit (U : Unit_Number_Type);
- -- Call Do_Node on the root node of a compilation unit
+ -- Call Do_Tree on the root node of a compilation unit
+
+ function Ancestor_Node (Count : Node_Stack_Count) return Node_Id;
+ -- Nth ancestor on the Node_Stack. Ancestor_Node(0) is the current node,
+ -- Ancestor_Node(1) is its parent, Ancestor_Node(2) is its grandparent,
+ -- and so on.
+
+ function Top_Node return Node_Id is (Ancestor_Node (0));
+
+ type Node_Set is array (Node_Id range <>) of Boolean;
+ pragma Pack (Node_Set);
+ type Node_Set_Ptr is access all Node_Set;
+ procedure Free is new Ada.Unchecked_Deallocation (Node_Set, Node_Set_Ptr);
+
+ Visited : Node_Set_Ptr;
+ -- Giant array of Booleans; Visited (N) is True if and only if we have
+ -- visited N in the tree walk. Used to detect incorrect sharing of subtrees
+ -- or (worse) cycles. We don't allocate the set on the stack, for fear of
+ -- Storage_Error.
+
+ function Get_Node_Field_Union is new
+ Atree.Atree_Private_Part.Get_32_Bit_Field (Union_Id) with Inline;
+
+ --------------
+ -- To_Mixed --
+ --------------
+
+ function To_Mixed (A : String) return String is
+ Result : String := A;
+ begin
+ System.Case_Util.To_Mixed (Result);
+ return Result;
+ end To_Mixed;
+
+ ---------
+ -- Put --
+ ---------
+
+ procedure Put (S : String) is
+ begin
+ if Debug.Debug_Flag_Underscore_WW then
+ Output.Write_Str (S);
+ end if;
+ end Put;
+
+ --------------
+ -- Put_Line --
+ --------------
+
+ procedure Put_Line (S : String) is
+ begin
+ if Debug.Debug_Flag_Underscore_WW then
+ Output.Write_Line (S);
+ end if;
+ end Put_Line;
+
+ --------------
+ -- Put_Node --
+ --------------
+
+ procedure Put_Node (N : Node_Id) is
+ begin
+ if Debug.Debug_Flag_Underscore_WW then
+ if Nkind (N) in N_Entity then
+ Put (Image (Ekind (N)));
+ else
+ Put (Image (Nkind (N)));
+ end if;
+
+ Put (N'Img & " ");
+ Sinput.Write_Location (Sloc (N));
+
+ if Comes_From_Source (N) then
+ Put (" (s)");
+ end if;
+
+ case Nkind (N) is
+ when N_Has_Chars =>
+ Put (" ");
+ Write_Name_For_Debug (Chars (N), Quote => """");
+ when others => null;
+ end case;
+
+ end if;
+ end Put_Node;
+
+ ---------------------
+ -- Put_Indentation --
+ ---------------------
+
+ procedure Put_Indentation is
+ begin
+ Put (String'(Natural (Node_Stack.First) ..
+ Natural (Node_Stack.Last) * 2 => ' '));
+ end Put_Indentation;
+
+ ----------------
+ -- Enter_Node --
+ ----------------
+
+ procedure Enter_Node (N : Node_Id) is
+ begin
+ Node_Stack.Append (N); -- push
+
+ if Has_Subtrees (N) then
+ Put ("-->");
+ else
+ -- If no subtrees, just print one line for enter/leave
+ Put (" ");
+ end if;
+ Put_Indentation;
+ Put_Node (N);
+ Put_Line ("");
+ end Enter_Node;
+
+ ----------------
+ -- Leave_Node --
+ ----------------
+
+ procedure Leave_Node (N : Node_Id) is
+ begin
+ if Has_Subtrees (N) then
+ Put ("<--");
+ Put_Indentation;
+ Put_Node (N);
+ Put_Line ("");
+ end if;
+
+ Node_Stack.Decrement_Last; -- pop
+ end Leave_Node;
+
+ --------------------
+ -- Put_Node_Stack --
+ --------------------
+
+ procedure Put_Node_Stack is
+ begin
+ for J in reverse Node_Stack.First .. Node_Stack.Last loop
+ Put_Node (Node_Stack.Table (J));
+ Put_Line ("");
+ end loop;
+ end Put_Node_Stack;
+
+ -------------------
+ -- Ancestor_Node --
+ -------------------
+
+ function Ancestor_Node (Count : Node_Stack_Count) return Node_Id is
+ begin
+ return Node_Stack.Table (Node_Stack.Last - Count);
+ end Ancestor_Node;
------------
-- Assert --
@@ -98,34 +325,70 @@ package body VAST is
declare
Part1 : constant String := "VAST fail";
Part2 : constant String :=
- (if Check = Check_Other then "" else ": " & Check'Img);
+ (if Check = Check_Other then ""
+ else ": " & To_Mixed (Check'Img));
Part3 : constant String :=
(if Detail = "" then "" else " -- " & Detail);
Message : constant String := Part1 & Part2 & Part3;
+ Save : constant Boolean := Debug.Debug_Flag_Underscore_WW;
begin
- if Enabled_Checks (Check) or else Print_Disabled_Failing_Checks
- then
- -- ???This Special_Output business is kind of ugly.
- -- We can do better.
- Cancel_Special_Output;
- Write_Line (Message);
- Set_Special_Output (Ignore_Output'Access);
- end if;
-
- if Enabled_Checks (Check) then
- raise VAST_Failure with Message;
- end if;
+ case Status (Check) is
+ when Disabled => null;
+ when Enabled | Print_And_Continue =>
+ Debug.Debug_Flag_Underscore_WW := True;
+ -- ???We should probably avoid changing the debug flag here
+ Put (Message & ": ");
+ Put_Node (Top_Node);
+ Put_Line ("");
+
+ if Status (Check) = Enabled then
+ Put_Node_Stack;
+ raise VAST_Failure with Message;
+ end if;
+
+ Debug.Debug_Flag_Underscore_WW := Save;
+ end case;
end;
end if;
end Assert;
-------------
- -- Do_Node --
+ -- Do_Tree --
-------------
- function Do_Node (N : Node_Id) return Traverse_Result is
+ procedure Do_Tree (N : Node_Id) is
begin
- Debug_A_Entry ("do ", N);
+ Enter_Node (N);
+
+ -- Skip the rest if empty. Check Sloc:
+
+ case Nkind (N) is
+ when N_Empty =>
+ Assert (No (Sloc (N)));
+ goto Done; -- -------------->
+ -- Don't do any further checks on Empty
+
+ -- ???Some nodes, including exception handlers, have no Sloc;
+ -- it's unclear why.
+
+ when N_Exception_Handler =>
+ Assert (if Comes_From_Source (N) then Present (Sloc (N)));
+ when others =>
+ Assert (Present (Sloc (N)), Check_Sloc);
+ end case;
+
+ -- All reachable nodes should have been analyzed by the time we get
+ -- here:
+
+ Assert (Analyzed (N), Check_Analyzed);
+
+ -- If we visit the same node more than once, then there are shared
+ -- nodes; the "tree" is not a tree:
+
+ Assert (not Visited (N), Check_Sharing);
+ Visited (N) := True;
+
+ -- Misc checks based on node/entity kind:
case Nkind (N) is
when N_Unused_At_Start | N_Unused_At_End =>
@@ -148,27 +411,105 @@ package body VAST is
-- Check that N has a Parent, except in certain cases:
- if Nkind (N) = N_Compilation_Unit then
- Assert (No (Parent (N)));
- -- The root of each unit should not have a parent
-
- elsif N in N_Entity_Id and then Is_Itype (N) then
- null; -- An Itype might or might not have a parent
+ case Nkind (N) is
+ when N_Empty =>
+ raise Program_Error; -- can't get here
- else
- if Nkind (N) = N_Error then
+ when N_Error =>
Assert (False, Check_Error_Nodes);
-- The error node has no parent, but we shouldn't even be seeing
- -- error nodes in VAST at all. See "when N_Error" above.
- else
- Assert (Present (Parent (N)), Detail => "missing parent");
+ -- error nodes in VAST at all. See earlier "when N_Error".
+
+ when N_Compilation_Unit =>
+ Assert (No (Parent (N)));
+ -- The parent of the root of each unit is empty.
+
+ when N_Entity =>
+ if not Is_Itype (N) then
+ -- An Itype might or might not have a parent
+
+ Assert
+ (Present (Parent (N)), Detail => "missing parent of entity");
+ Assert (Parent (N) = Ancestor_Node (1), Check_Parent_Correct);
+ end if;
+
+ when others =>
+ Assert (Present (Parent (N)), Check_Parent_Present);
-- All other nodes should have a parent
- end if;
- end if;
+ if Status (Check_Parent_Present) = Enabled then
+ Assert (Parent (N) = Ancestor_Node (1), Check_Parent_Correct);
+ end if;
+ end case;
- Debug_A_Exit ("do ", N, " (done)");
- return OK;
- end Do_Node;
+ Do_Subtrees (N);
+
+ <<Done>>
+ Leave_Node (N);
+ end Do_Tree;
+
+ -----------------
+ -- Has_Subtrees --
+ -----------------
+
+ function Has_Subtrees (N : Node_Id) return Boolean is
+ Offsets : Traversed_Offset_Array renames
+ Traversed_Fields (Nkind (N));
+ begin
+ -- True if sentinel comes first
+ return Offsets (Offsets'First) /= No_Field_Offset;
+ end Has_Subtrees;
+
+ -----------------
+ -- Do_Subtrees --
+ -----------------
+
+ procedure Do_Subtrees (N : Node_Id) is
+ -- ???Do we need tail recursion elimination here,
+ -- as in Atree.Traverse_Func?
+ Offsets : Traversed_Offset_Array renames
+ Traversed_Fields (Nkind (N));
+ begin
+ for Cur_Field in Offset_Array_Index loop
+ exit when Offsets (Cur_Field) = No_Field_Offset;
+
+ declare
+ F : constant Union_Id :=
+ Get_Node_Field_Union (N, Offsets (Cur_Field));
+ begin
+ if F in Node_Range then
+ Do_Tree (Node_Id (F));
+ elsif F in List_Range then
+ Do_List (List_Id (F));
+ else
+ raise Program_Error;
+ end if;
+ end;
+ end loop;
+ end Do_Subtrees;
+
+ -------------
+ -- Do_List --
+ -------------
+
+ procedure Do_List (L : List_Id) is
+ Elmt : Node_Id := First (L);
+ Len : constant String := List_Length (L)'Img;
+ begin
+ if Is_Non_Empty_List (L) then
+ Put ("-->");
+ Put_Indentation;
+ Put_Line ("list len=" & Len);
+
+ while Present (Elmt) loop
+ Do_Tree (Elmt);
+ Next (Elmt);
+ end loop;
+
+ Put ("<--");
+ Put_Indentation;
+ Put_Line ("list len=" & Len);
+ end if;
+ end Do_List;
-------------
-- Do_Unit --
@@ -183,8 +524,10 @@ package body VAST is
(if Is_Predefined_Unit (U) then " (predef)"
elsif Is_Internal_Unit (U) then " (gnat)"
else "");
+ Is_Main : constant String :=
+ (if U = Main_Unit then " (main unit)" else "");
Msg : constant String :=
- "VAST for unit" & U'Img & " " & U_Name_S & Predef;
+ "VAST for unit" & U'Img & " " & U_Name_S & Predef & Is_Main;
Is_Preprocessing_Dependency : constant Boolean :=
U_Name = No_Unit_Name;
@@ -194,24 +537,26 @@ package body VAST is
Root : constant Node_Id := Cunit (U);
begin
+ pragma Assert (Node_Stack.Last = 0);
Assert (No (Root) = Is_Preprocessing_Dependency);
-- All compilation units except these bogus ones should have a Cunit.
- Write_Line (Msg);
+ Put_Line (Msg);
if Is_Preprocessing_Dependency then
- Write_Line ("Skipping preprocessing dependency");
+ Put_Line ("Skipping preprocessing dependency");
return;
end if;
Assert (Present (Root));
- Traverse (Root);
- Write_Line (Msg & " (done)");
+ Do_Tree (Root);
+ Put_Line (Msg & " (done)");
+ pragma Assert (Node_Stack.Last = 0);
end Do_Unit;
- ----------------
- -- Check_Tree --
- ----------------
+ ----------
+ -- VAST --
+ ----------
procedure VAST is
pragma Assert (Expander_Active = (Operating_Mode = Generate_Code));
@@ -228,12 +573,10 @@ package body VAST is
end if;
-- If -gnatd_W (VAST in verbose mode) is enabled, then that should imply
- -- -gnatd_V (enable VAST). In addition, we use the Debug_A routines to
- -- print debugging information, so enable -gnatda.
+ -- -gnatd_V (enable VAST).
if Debug_Flag_Underscore_WW then
Debug_Flag_Underscore_VV := True;
- Debug_Flag_A := True;
end if;
-- Do nothing if VAST is disabled
@@ -244,22 +587,34 @@ package body VAST is
-- Turn off output unless verbose mode is enabled
- if not Debug_Flag_Underscore_WW then
- Set_Special_Output (Ignore_Output'Access);
- end if;
- Write_Line ("VAST");
+ Put_Line ("VAST");
-- Operating_Mode = Generate_Code implies there are no legality errors:
Assert (Serious_Errors_Detected = 0);
- Write_Line ("VAST checking" & Last_Unit'Img & " units");
- for U in Main_Unit .. Last_Unit loop
- Do_Unit (U);
- end loop;
+ Put_Line ("VAST checking" & Last_Unit'Img & " units");
+
+ declare
+ use Atree_Private_Part;
+ Last_Node : constant Node_Id := Node_Offsets.Last;
+ begin
+ pragma Assert (Visited = null);
+ Visited := new Node_Set'(Node_Id'First .. Last_Node => False);
+
+ for U in Main_Unit .. Last_Unit loop
+ -- Main_Unit is the one passed to the back end, but here we are
+ -- walking all the units.
+ Do_Unit (U);
+ end loop;
+
+ -- We shouldn't have allocated any new nodes during VAST:
+
+ pragma Assert (Node_Offsets.Last = Last_Node);
+ Free (Visited);
+ end;
- Write_Line ("VAST done.");
- Cancel_Special_Output;
+ Put_Line ("VAST done.");
end VAST;
end VAST;