aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2024-08-26 18:56:37 +0000
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-09-10 09:44:10 +0200
commit356536a4e6bce777e9f150e0bdcd627cd73068cd (patch)
treec1085702b53d5efd77ede964ef44c84173fd0f2c /gcc
parent5b701ee737c41cd0ca54f1343620170d92344e6a (diff)
downloadgcc-356536a4e6bce777e9f150e0bdcd627cd73068cd.zip
gcc-356536a4e6bce777e9f150e0bdcd627cd73068cd.tar.gz
gcc-356536a4e6bce777e9f150e0bdcd627cd73068cd.tar.bz2
ada: First controlling parameter: report error without Extensions allowed
Enable reporting an error when this new aspect/pragma is set to True, and the sources are compiled without language extensions allowed. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Call Error_Msg_GNAT_Extension() to report an error when the aspect First_Controlling_Parameter is set to True and the sources are compiled without Core_Extensions_ Allowed. * sem_prag.adb (Pragma_First_Controlling_Parameter): Call subprogram Error_Msg_GNAT_Extension() to report an error when the aspect First_Controlling_Parameter is set to True and the sources are compiled without Core_Extensions_Allowed. Report an error when the aspect pragma does not confirm an inherited True value.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch13.adb28
-rw-r--r--gcc/ada/sem_prag.adb53
2 files changed, 61 insertions, 20 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index ab8cc10..0770baf 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -4530,6 +4530,9 @@ package body Sem_Ch13 is
if (No (Expr) or else Entity (Expr) = Standard_True)
and then not Core_Extensions_Allowed
then
+ Error_Msg_GNAT_Extension
+ ("'First_'Controlling_'Parameter", Sloc (Aspect),
+ Is_Core_Extension => True);
goto Continue;
end if;
@@ -4545,19 +4548,24 @@ package body Sem_Ch13 is
goto Continue;
end if;
- -- If the aspect is specified for a derived type, the
- -- specified value shall be confirming.
-
if Present (Expr)
- and then Is_Derived_Type (E)
- and then
- Has_First_Controlling_Parameter_Aspect (Etype (E))
and then Entity (Expr) = Standard_False
then
- Error_Msg_Name_1 := Nam;
- Error_Msg_N
- ("specification of inherited aspect% can only "
- & "confirm parent value", Id);
+ -- If the aspect is specified for a derived type,
+ -- the specified value shall be confirming.
+
+ if Is_Derived_Type (E)
+ and then Has_First_Controlling_Parameter_Aspect
+ (Etype (E))
+ then
+ Error_Msg_Name_1 := Nam;
+ Error_Msg_N
+ ("specification of inherited True value for "
+ & "aspect% can only confirm parent value",
+ Id);
+ end if;
+
+ goto Continue;
end if;
-- Given that the aspect has been explicitly given,
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index b139bd4..2d31c71 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -17761,22 +17761,55 @@ package body Sem_Prag is
----------------------------------------
when Pragma_First_Controlling_Parameter => First_Ctrl_Param : declare
- Arg : Node_Id;
- E : Entity_Id := Empty;
+ Arg : Node_Id;
+ E : Entity_Id := Empty;
+ Expr : Node_Id := Empty;
begin
- if not Core_Extensions_Allowed then
- return;
- end if;
-
GNAT_Pragma;
- Check_Arg_Count (1);
+ Check_At_Least_N_Arguments (1);
+ Check_At_Most_N_Arguments (2);
Arg := Get_Pragma_Arg (Arg1);
+ Check_Arg_Is_Identifier (Arg);
- if Nkind (Arg) = N_Identifier then
- Analyze (Arg);
- E := Entity (Arg);
+ Analyze (Arg);
+ E := Entity (Arg);
+
+ if Present (Arg2) then
+ Check_Arg_Is_OK_Static_Expression (Arg2, Standard_Boolean);
+ Expr := Get_Pragma_Arg (Arg2);
+ Analyze_And_Resolve (Expr, Standard_Boolean);
+ end if;
+
+ if not Core_Extensions_Allowed then
+ if No (Expr)
+ or else
+ (Present (Expr)
+ and then Is_Entity_Name (Expr)
+ and then Entity (Expr) = Standard_True)
+ then
+ Error_Msg_GNAT_Extension
+ ("'First_'Controlling_'Parameter", Sloc (N),
+ Is_Core_Extension => True);
+ end if;
+
+ return;
+
+ elsif Present (Expr)
+ and then Is_Entity_Name (Expr)
+ and then Entity (Expr) = Standard_False
+ then
+ if Is_Derived_Type (E)
+ and then Has_First_Controlling_Parameter_Aspect (Etype (E))
+ then
+ Error_Msg_Name_1 := Name_First_Controlling_Parameter;
+ Error_Msg_N
+ ("specification of inherited True value for aspect% can "
+ & "only confirm parent value", Pragma_Identifier (N));
+ end if;
+
+ return;
end if;
if No (E)