From 1e78b49adb52ccf9493515ae002d87f3af1f5de9 Mon Sep 17 00:00:00 2001 From: Steve Baird Date: Fri, 30 Sep 2022 15:27:00 -0700 Subject: 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. --- gcc/ada/sem_ch5.adb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/ada/sem_ch5.adb') diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index d0f00b3..ac49523 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1614,7 +1614,7 @@ package body Sem_Ch5 is -- out non-discretes may resolve the ambiguity. -- But GNAT extensions allow casing on non-discretes. - elsif Extensions_Allowed and then Is_Overloaded (Exp) then + elsif Core_Extensions_Allowed and then Is_Overloaded (Exp) then -- It would be nice if we could generate all the right error -- messages by calling "Resolve (Exp, Any_Type);" in the @@ -1632,7 +1632,7 @@ package body Sem_Ch5 is -- Check for a GNAT-extension "general" case statement (i.e., one where -- the type of the selecting expression is not discrete). - elsif Extensions_Allowed + elsif Core_Extensions_Allowed and then not Is_Discrete_Type (Etype (Exp)) then Resolve (Exp, Etype (Exp)); @@ -1670,7 +1670,7 @@ package body Sem_Ch5 is ("(Ada 83) case expression cannot be of a generic type", Exp); return; - elsif not Extensions_Allowed + elsif not Core_Extensions_Allowed and then not Is_Discrete_Type (Exp_Type) then Error_Msg_N -- cgit v1.1