]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Allow formal functions to have a default in the form of an expression function
authorGary Dismukes <dismukes@adacore.com>
Tue, 16 Nov 2021 21:56:44 +0000 (16:56 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 1 Dec 2021 10:24:43 +0000 (10:24 +0000)
commit38e7e9ac1591ca3e7b3adc181a0786fd71739b40
treec4533bba0912690a6e88865edb94e81a9e8c4d60
parentbbafa6251ed34c3753d3efd821338b493cc957e0
[Ada] Allow formal functions to have a default in the form of an expression function

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Add
documentation of the new form of formal subprogram default in
the section on language extensions (pragma Extensions_Allowed).
* gnat_rm.texi: Regenerate.
* gen_il-gen-gen_nodes.adb: Add Expression as a syntactic field
of N_Formal_(Abstract|Concrete)_Subprogram_Declaration nodes.
* par-ch12.adb (P_Formal_Subprogram_Declaration): Add parsing
support for the new default of a parenthesized expression for
formal functions. Issue an error when extensions are not
allowed, suggesting use of -gnatX. Update comment with extended
syntax for SUBPROGRAM_DEFAULT.
* sem_ch12.adb (Analyze_Formal_Subprogram_Declaration): Issue an
error when an expression default is given for an abstract formal
function. When a default expression is present for a formal
function, install the function's formals and preanalyze the
expression.
(Instantiate_Formal_Subprogram): Fix typo in RM paragraph in a
comment.  When a formal function has a default expression,
create a body for the function that will evaluate the expression
and will be called when the default applies in an instantiation.
The implicit function is marked as inlined and as having
convention Intrinsic.
gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/gnat_rm.texi
gcc/ada/par-ch12.adb
gcc/ada/sem_ch12.adb