Reuse Error_Msg_Ada_2020_Feature to complain about a missing -gnat2020
switch when code that would be legal in Ada 2020 is compiled in an
earlier language version.
Also, refer to language construct and not to syntactic category of the
missing feature, i.e. "declare expression" and not "declare_expression".
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* par-ch3.adb (P_Identifier_Declarations): Reuse
Error_Msg_Ada_2020_Feature for object renaming without subtype.
* par-ch4.adb (P_Primary): Likewise for target name.
(P_Iterated_Component_Association): Likewise for iterated
component.
(P_Declare_Expression): Likewise for declare expression.
* par-ch6.adb (P_Formal_Part): Likewise for aspect on formal
parameter.
* sem_aggr.adb (Resolve_Delta_Aggregate): Ditto.
* sem_ch8.adb (Analyze_Object_Renaming): Reuse
Error_Msg_Ada_2020_Feature.
* sem_ch13.adb (Validate_Aspect_Aggregate): Reuse
Error_Msg_Ada_2020_Feature; use lower case for "aspect" and
don't use underscore for "Ada_2020"; don't give up on analysis
in Ada 2012 mode.
(Validate_Aspect_Stable_Properties): Reuse
Error_Msg_Ada_2020_Feature; use lower case for "aspect"; minor
style fixes.
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -1486,11 +1486,8 @@ package body Ch3 is
-- access_definition
elsif Token = Tok_Renames then
- if Ada_Version < Ada_2020 then
- Error_Msg_SC
- ("object renaming without subtype is an Ada 202x feature");
- Error_Msg_SC ("\compile with -gnat2020");
- end if;
+ Error_Msg_Ada_2020_Feature
+ ("object renaming without subtype", Token_Ptr);
Scan; -- past renames
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -2928,10 +2928,7 @@ package body Ch4 is
Scan; -- past minus
when Tok_At_Sign => -- AI12-0125 : target_name
- if Ada_Version < Ada_2020 then
- Error_Msg_SC ("target name is an Ada 202x feature");
- Error_Msg_SC ("\compile with -gnat2020");
- end if;
+ Error_Msg_Ada_2020_Feature ("target name", Token_Ptr);
Node1 := P_Name;
return Node1;
@@ -3507,10 +3504,7 @@ package body Ch4 is
Set_Expression (Assoc_Node, P_Expression);
end if;
- if Ada_Version < Ada_2020 then
- Error_Msg_SC ("iterated component is an Ada 202x feature");
- Error_Msg_SC ("\compile with -gnat2020");
- end if;
+ Error_Msg_Ada_2020_Feature ("iterated component", Token_Ptr);
return Assoc_Node;
end P_Iterated_Component_Association;
@@ -3695,9 +3689,7 @@ package body Ch4 is
Result : constant Node_Id :=
Make_Expression_With_Actions (Loc, Actions, Expression);
begin
- if Ada_Version < Ada_2020 then
- Error_Msg ("declare_expression is an Ada 2020 feature", Loc);
- end if;
+ Error_Msg_Ada_2020_Feature ("declare expression", Loc);
return Result;
end;
diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb
--- a/gcc/ada/par-ch6.adb
+++ b/gcc/ada/par-ch6.adb
@@ -1620,9 +1620,8 @@ package body Ch6 is
-- the time being.
elsif Token = Tok_With then
- if Ada_Version < Ada_2020 then
- Error_Msg_SP ("aspect on formal parameter requires -gnat2020");
- end if;
+ Error_Msg_Ada_2020_Feature
+ ("aspect on formal parameter", Token_Ptr);
P_Aspect_Specifications (Specification_Node, False);
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3035,10 +3035,7 @@ package body Sem_Aggr is
Base : constant Node_Id := Expression (N);
begin
- if Ada_Version < Ada_2020 then
- Error_Msg_N ("delta_aggregate is an Ada 202x feature", N);
- Error_Msg_N ("\compile with -gnat2020", N);
- end if;
+ Error_Msg_Ada_2020_Feature ("delta aggregate", Sloc (N));
if not Is_Composite_Type (Typ) then
Error_Msg_N ("not a composite type", N);
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -15166,14 +15166,13 @@ package body Sem_Ch13 is
Assign_Indexed_Subp : Node_Id := Empty;
begin
- if Ada_Version < Ada_2020 then
- Error_Msg_N ("Aspect Aggregate is an Ada_2020 feature", N);
+ Error_Msg_Ada_2020_Feature ("aspect Aggregate", Sloc (N));
- elsif Nkind (N) /= N_Aggregate
+ if Nkind (N) /= N_Aggregate
or else Present (Expressions (N))
or else No (Component_Associations (N))
then
- Error_Msg_N ("Aspect Aggregate requires an aggregate "
+ Error_Msg_N ("aspect Aggregate requires an aggregate "
& "with component associations", N);
return;
end if;
@@ -15251,7 +15250,8 @@ package body Sem_Ch13 is
PF_Name : Node_Id := PF_Arg;
- -- Start of processing for Check_Property_Function_Arg
+ -- Start of processing for Check_Property_Function_Arg
+
begin
if Nkind (PF_Arg) = N_Op_Not then
PF_Name := Right_Opnd (PF_Arg);
@@ -15282,10 +15282,10 @@ package body Sem_Ch13 is
end if;
end Check_Property_Function_Arg;
+ -- Start of processing for Validate_Aspect_Stable_Properties
+
begin
- if Ada_Version < Ada_2020 then
- Error_Msg_N ("Aspect Stable_Properties is an Ada_2020 feature", N);
- end if;
+ Error_Msg_Ada_2020_Feature ("aspect Stable_Properties", Sloc (N));
if (not Is_Aspect_Of_Type) and then (not Is_Subprogram (E)) then
Error_Msg_N ("Stable_Properties aspect can only be specified for "
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -1482,10 +1482,8 @@ package body Sem_Ch8 is
-- AI12-0383: Names that denote values can be renamed.
-- Ignore (accept) N_Raise_xxx_Error nodes in this context.
- elsif Ada_Version < Ada_2020
- and then No_Raise_xxx_Error (Nam) = OK
- then
- Error_Msg_N ("value in renaming requires -gnat2020", Nam);
+ elsif No_Raise_xxx_Error (Nam) = OK then
+ Error_Msg_Ada_2020_Feature ("value in renaming", Sloc (Nam));
end if;
Set_Etype (Id, T2);