aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/errout.ads
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2022-09-30 15:27:00 -0700
committerMarc Poulhiès <poulhies@adacore.com>2022-11-04 14:47:24 +0100
commit1e78b49adb52ccf9493515ae002d87f3af1f5de9 (patch)
treedc255aac6355787df6cee090f9da4a9d79571a6a /gcc/ada/errout.ads
parentc07da8567bfc67bd28191f63a9247566260063ad (diff)
downloadgcc-1e78b49adb52ccf9493515ae002d87f3af1f5de9.zip
gcc-1e78b49adb52ccf9493515ae002d87f3af1f5de9.tar.gz
gcc-1e78b49adb52ccf9493515ae002d87f3af1f5de9.tar.bz2
ada: Allow enabling a restricted set of language extensions.
The -gnatX switch (and the related Extensions_Allowed pragma) is currently a two-valued all-or-nothing option. Add support for enabling a curated subset of language extensions without enabling others via the -gnatX switch and for enabling all language extensions via the new -gnatX0 switch. Similarly, the existing "ON" argument for the Extensions_Allowed pragma now only enables the curated subset; the new argument "ALL" enables all language extensions. The subset of language extensions currently includes prefixed-view notation with an untagged prefix, fixed-low-bound array subtypes, and casing on composite values. gcc/ada/ * opt.ads: Replace Ada_Version_Type enumeration literal Ada_With_Extensions with two literals, Ada_With_Core_Extensions and Ada_With_All_Extensions. Update uses of the deleted literal. Replace Extensions_Allowed function with two functions: All_Extensions_Allowed and Core_Extensions_Allowed. * errout.ads, errout.adb: Add Boolean parameter to Error_Msg_GNAT_Extension to indicate whether the construct in question belongs to the curated subset. * exp_ch5.adb, par-ch4.adb, sem_case.adb, sem_ch3.adb: * sem_ch4.adb, sem_ch5.adb, sem_ch8.adb: Replace calls to Extensions_Allowed with calls to Core_Extensions_Allowed for constructs that are in the curated subset. * sem_attr.adb, sem_ch13.adb, sem_eval.adb, sem_util.adb: Replace calls to Extensions_Allowed with calls to All_Extensions_Allowed for constructs that are not in the curated subset. * par-ch3.adb: Override default for new parameter in calls to Error_Msg_GNAT_Extension for constructs in the curated subset. * par-prag.adb: Add Boolean parameter to Check_Arg_Is_On_Or_Off to also allow ALL. Set Opt.Ada_Version appropriately for ALL or ON arguments. * sem_prag.adb: Allowed ALL argument for an Extensions_Allowed pragma. Set Opt.Ada_Version appropriately for ALL or ON arguments. * switch-c.adb: The -gnatX switch now enables only the curated subset of language extensions (formerly it enabled all of them); the new -gnatX0 switch enables all of them. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Document new "-gnatX0" switch and update documentation for "-gnatX" switch. * doc/gnat_rm/implementation_defined_pragmas.rst: Document new ALL argument for pragma Extensions_Allowed and update documentation for the ON argument. Delete mention of Ada 2022 Reduce attribute as an extension. * gnat_rm.texi, gnat_ugn.texi: Regenerate.
Diffstat (limited to 'gcc/ada/errout.ads')
-rw-r--r--gcc/ada/errout.ads17
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads
index 45166f5..78fe514 100644
--- a/gcc/ada/errout.ads
+++ b/gcc/ada/errout.ads
@@ -937,11 +937,18 @@ package Errout is
procedure Error_Msg_Ada_2022_Feature (Feature : String; Loc : Source_Ptr);
-- Analogous to Error_Msg_Ada_2012_Feature, for Ada 2022
- procedure Error_Msg_GNAT_Extension (Extension : String; Loc : Source_Ptr);
- -- If not operating with extensions allowed, posts errors complaining
- -- that Extension is only supported when the -gnatX switch is enabled
- -- or pragma Extensions_Allowed (On) is used. Loc indicates the source
- -- location of the extension construct.
+ procedure Error_Msg_GNAT_Extension
+ (Extension : String;
+ Loc : Source_Ptr;
+ Is_Core_Extension : Boolean := False);
+ -- To be called as part of checking a GNAT language extension (either a
+ -- core extension or not, as indicated by the Is_Core_Extension parameter).
+ -- If switch -gnatX0 or pragma Extension_Allowed (All) is in effect, then
+ -- either kind of extension is allowed; if switch -gnatX or pragma
+ -- Extensions_Allowed (On) is in effect, then only core extensions are
+ -- allowed. Otherwise, no extensions are allowed. A disallowed construct
+ -- is flagged as an error. Loc indicates the source location of the
+ -- extension construct.
procedure dmsg (Id : Error_Msg_Id) renames Erroutc.dmsg;
-- Debugging routine to dump an error message