[Ada] Refactor repeated complains about missing -gnat2005 switch
gcc/ada/ * errout.ads (Error_Msg_Ada_2005_Extension): New routine (spec). * errout.adb (Error_Msg_Ada_2005_Extension): New routine (body). * par-ch10.adb: Reuse new routine; correct casing for "LIMITED WITH". * par-ch11.adb: Likewise. * par-ch12.adb: Likewise. * par-ch3.adb: Likewise. * par-ch4.adb: Likewise; replace "box" with "<>". * par-ch6.adb: Likewise. * par-ch9.adb: Likewise; correct casing for "THEN ABORT".
This commit is contained in:
parent
04974721ae
commit
3a6298d639
@ -612,6 +612,25 @@ package body Errout is
|
||||
end;
|
||||
end Error_Msg;
|
||||
|
||||
----------------------------------
|
||||
-- Error_Msg_Ada_2005_Extension --
|
||||
----------------------------------
|
||||
|
||||
procedure Error_Msg_Ada_2005_Extension (Extension : String) is
|
||||
Loc : constant Source_Ptr := Token_Ptr;
|
||||
begin
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg (Extension & " is an Ada 2005 extension", Loc);
|
||||
|
||||
if No (Ada_Version_Pragma) then
|
||||
Error_Msg ("\unit must be compiled with -gnat05 switch", Loc);
|
||||
else
|
||||
Error_Msg_Sloc := Sloc (Ada_Version_Pragma);
|
||||
Error_Msg ("\incompatible with Ada version set#", Loc);
|
||||
end if;
|
||||
end if;
|
||||
end Error_Msg_Ada_2005_Extension;
|
||||
|
||||
--------------------------------
|
||||
-- Error_Msg_Ada_2012_Feature --
|
||||
--------------------------------
|
||||
|
@ -902,6 +902,11 @@ package Errout is
|
||||
-- overridden interface primitive Iface_Prim) indicating wrong mode of the
|
||||
-- first formal (RM 9.4(11.9/3)).
|
||||
|
||||
procedure Error_Msg_Ada_2005_Extension (Extension : String);
|
||||
-- Analogous to Error_Msg_Ada_2012_Feature, but phrase the message using
|
||||
-- "extension" and not "feature". This routine is only used in the parser,
|
||||
-- so the error is always placed at the Token_Ptr.
|
||||
|
||||
procedure Error_Msg_Ada_2012_Feature (Feature : String; Loc : Source_Ptr);
|
||||
-- If not operating in Ada 2012 mode or higher, posts errors complaining
|
||||
-- that Feature is only supported in Ada 2012, with appropriate suggestions
|
||||
|
@ -861,11 +861,7 @@ package body Ch10 is
|
||||
("unexpected LIMITED ignored");
|
||||
end if;
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("LIMITED WITH is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("`LIMITED WITH`");
|
||||
|
||||
elsif Token = Tok_Private then
|
||||
Has_Limited := False;
|
||||
@ -879,13 +875,10 @@ package body Ch10 is
|
||||
|
||||
Restore_Scan_State (Scan_State); -- to PRIVATE
|
||||
return Item_List;
|
||||
|
||||
elsif Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("`PRIVATE WITH` is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
|
||||
Error_Msg_Ada_2005_Extension ("`PRIVATE WITH`");
|
||||
|
||||
else
|
||||
Has_Limited := False;
|
||||
Has_Private := False;
|
||||
|
@ -227,10 +227,7 @@ package body Ch11 is
|
||||
end if;
|
||||
|
||||
if Token = Tok_With then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SC ("string expression in raise is Ada 2005 extension");
|
||||
Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("string expression in raise");
|
||||
|
||||
Scan; -- past WITH
|
||||
Set_Expression (Raise_Node, P_Expression);
|
||||
|
@ -349,13 +349,8 @@ package body Ch12 is
|
||||
-- Ada 2005: an association can be given by: others => <>
|
||||
|
||||
if Token = Tok_Others then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("partial parameterization of formal packages"
|
||||
& " is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("partial parameterization of formal package");
|
||||
|
||||
Scan; -- past OTHERS
|
||||
|
||||
@ -478,12 +473,8 @@ package body Ch12 is
|
||||
Set_Access_Definition (Decl_Node,
|
||||
P_Access_Definition (Not_Null_Present));
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("access definition not allowed in formal object " &
|
||||
"declaration");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("access definition in formal object declaration");
|
||||
|
||||
-- Formal object with a subtype mark
|
||||
|
||||
@ -923,23 +914,13 @@ package body Ch12 is
|
||||
Set_Limited_Present (Def_Node);
|
||||
Scan; -- past LIMITED
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("LIMITED in derived type is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("LIMITED in derived type");
|
||||
|
||||
elsif Token = Tok_Synchronized then
|
||||
Set_Synchronized_Present (Def_Node);
|
||||
Scan; -- past SYNCHRONIZED
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("SYNCHRONIZED in derived type is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("SYNCHRONIZED in derived type");
|
||||
end if;
|
||||
|
||||
if Token = Tok_Abstract then
|
||||
@ -955,11 +936,7 @@ package body Ch12 is
|
||||
if Token = Tok_And then
|
||||
Scan; -- past AND
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("abstract interface is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("abstract interface");
|
||||
|
||||
Set_Interface_List (Def_Node, New_List);
|
||||
|
||||
@ -1190,11 +1167,7 @@ package body Ch12 is
|
||||
New_Node (N_Formal_Abstract_Subprogram_Declaration, Prev_Sloc);
|
||||
Scan; -- past ABSTRACT
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("formal abstract subprograms are an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("formal abstract subprogram");
|
||||
|
||||
else
|
||||
Def_Node :=
|
||||
@ -1214,11 +1187,7 @@ package body Ch12 is
|
||||
Scan; -- past <>
|
||||
|
||||
elsif Token = Tok_Null then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("null default subprograms are an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("null default subprogram");
|
||||
|
||||
if Nkind (Spec_Node) = N_Procedure_Specification then
|
||||
Set_Null_Present (Spec_Node);
|
||||
|
@ -690,12 +690,7 @@ package body Ch3 is
|
||||
-- Ada 2005 (AI-419): LIMITED NEW
|
||||
|
||||
elsif Token = Tok_New then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("LIMITED in derived type is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("LIMITED in derived type");
|
||||
|
||||
Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl;
|
||||
Set_Limited_Present (Typedef_Node);
|
||||
@ -1671,13 +1666,8 @@ package body Ch3 is
|
||||
Set_Null_Exclusion_Present (Decl_Node, Not_Null_Present);
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("generalized use of anonymous access types " &
|
||||
"is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("generalized use of anonymous access types");
|
||||
|
||||
Set_Object_Definition
|
||||
(Decl_Node, P_Access_Definition (Not_Null_Present));
|
||||
@ -1734,13 +1724,8 @@ package body Ch3 is
|
||||
-- Access definition (AI-406) or subtype indication
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("generalized use of anonymous access types " &
|
||||
"is an Ada 2005 extension");
|
||||
Error_Msg_SP
|
||||
("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("generalized use of anonymous access types");
|
||||
|
||||
Set_Object_Definition
|
||||
(Decl_Node, P_Access_Definition (Not_Null_Present));
|
||||
@ -1779,12 +1764,8 @@ package body Ch3 is
|
||||
Not_Null_Present := P_Null_Exclusion; -- Ada 2005 (AI-231/423)
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("generalized use of anonymous access types " &
|
||||
"is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("generalized use of anonymous access types");
|
||||
|
||||
Acc_Node := P_Access_Definition (Not_Null_Present);
|
||||
|
||||
@ -1850,12 +1831,8 @@ package body Ch3 is
|
||||
-- Ada 2005 (AI-230): Access Definition case
|
||||
|
||||
elsif Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("generalized use of anonymous access types " &
|
||||
"is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("generalized use of anonymous access types");
|
||||
|
||||
Acc_Node := P_Access_Definition (Null_Exclusion_Present => False);
|
||||
|
||||
@ -2063,11 +2040,7 @@ package body Ch3 is
|
||||
if Token = Tok_And then
|
||||
Scan; -- past AND
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("abstract interface is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("abstract interface");
|
||||
|
||||
Set_Interface_List (Typedef_Node, New_List);
|
||||
|
||||
@ -2795,12 +2768,8 @@ package body Ch3 is
|
||||
-- Ada 2005 (AI-230): Access Definition case
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("generalized use of anonymous access types " &
|
||||
"is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("generalized use of anonymous access types");
|
||||
|
||||
-- AI95-406 makes "aliased" legal (and useless) in this context so
|
||||
-- followintg code which used to be needed is commented out.
|
||||
@ -3608,12 +3577,8 @@ package body Ch3 is
|
||||
-- Ada 2005 (AI-230): Access Definition case
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("generalized use of anonymous access types " &
|
||||
"is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension
|
||||
("generalized use of anonymous access types");
|
||||
|
||||
-- AI95-406 makes "aliased" legal (and useless) here, so the
|
||||
-- following code which used to be required is commented out.
|
||||
@ -3953,10 +3918,7 @@ package body Ch3 is
|
||||
Typedef_Node : Node_Id;
|
||||
|
||||
begin
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("abstract interface is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("abstract interface");
|
||||
|
||||
if Abstract_Present then
|
||||
Error_Msg_SP
|
||||
@ -4143,11 +4105,7 @@ package body Ch3 is
|
||||
-- Ada 2005 (AI-318-02)
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SC
|
||||
("anonymous access result type is an Ada 2005 extension");
|
||||
Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("anonymous access result type");
|
||||
|
||||
Result_Node := P_Access_Definition (Result_Not_Null);
|
||||
|
||||
@ -4245,10 +4203,7 @@ package body Ch3 is
|
||||
or else Token = Tok_Procedure
|
||||
or else Token = Tok_Function
|
||||
then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("access-to-subprogram is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit should be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("access-to-subprogram");
|
||||
|
||||
Subp_Node := P_Access_Type_Definition (Header_Already_Parsed => True);
|
||||
Set_Null_Exclusion_Present (Subp_Node, Null_Exclusion_Present);
|
||||
@ -4270,10 +4225,7 @@ package body Ch3 is
|
||||
Set_All_Present (Def_Node);
|
||||
|
||||
elsif Token = Tok_Constant then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("access-to-constant is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit should be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("access-to-constant");
|
||||
|
||||
Scan; -- past CONSTANT
|
||||
Set_Constant_Present (Def_Node);
|
||||
|
@ -1360,9 +1360,7 @@ package body Ch4 is
|
||||
|
||||
procedure Box_Error is
|
||||
begin
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SC ("box in aggregate is an Ada 2005 extension");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("'<'> in aggregate");
|
||||
|
||||
-- Ada 2005 (AI-287): The box notation is allowed only with named
|
||||
-- notation because positional notation might be error prone. For
|
||||
@ -1755,11 +1753,7 @@ package body Ch4 is
|
||||
-- Ada 2005(AI-287): The box notation is used to indicate the
|
||||
-- default initialization of aggregate components
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
("component association with '<'> is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("component association with '<'>");
|
||||
|
||||
Set_Box_Present (Assoc_Node);
|
||||
Scan; -- Past box
|
||||
|
@ -426,11 +426,7 @@ package body Ch6 is
|
||||
-- Ada 2005 (AI-318-02)
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SC
|
||||
("anonymous access result type is an Ada 2005 extension");
|
||||
Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("anonymous access result type");
|
||||
|
||||
Result_Node := P_Access_Definition (Result_Not_Null);
|
||||
|
||||
@ -598,10 +594,7 @@ package body Ch6 is
|
||||
-- Ada 2005 (AI-248): Parse a null procedure declaration
|
||||
|
||||
elsif Token = Tok_Null then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("null procedures are an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("null procedure");
|
||||
|
||||
Scan; -- past NULL
|
||||
|
||||
@ -1064,11 +1057,7 @@ package body Ch6 is
|
||||
-- Ada 2005 (AI-318-02)
|
||||
|
||||
if Token = Tok_Access then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SC
|
||||
("anonymous access result type is an Ada 2005 extension");
|
||||
Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("anonymous access result type");
|
||||
|
||||
Result_Node := P_Access_Definition (Result_Not_Null);
|
||||
|
||||
@ -1950,11 +1939,7 @@ package body Ch6 is
|
||||
-- Extended_return_statement (Ada 2005 only -- AI-318):
|
||||
|
||||
else
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP
|
||||
(" extended_return_statement is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("extended return statement");
|
||||
|
||||
Ret_Node := New_Node (N_Extended_Return_Statement, Ret_Sloc);
|
||||
Decl := P_Return_Object_Declaration;
|
||||
|
@ -220,10 +220,7 @@ package body Ch9 is
|
||||
if Token = Tok_New then
|
||||
Scan; -- past NEW
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("task interface is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("task interface");
|
||||
|
||||
Set_Interface_List (Task_Node, New_List);
|
||||
|
||||
@ -565,10 +562,7 @@ package body Ch9 is
|
||||
if Token = Tok_New then
|
||||
Scan; -- past NEW
|
||||
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("protected interface is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
end if;
|
||||
Error_Msg_Ada_2005_Extension ("protected interface");
|
||||
|
||||
Set_Interface_List (Protected_Node, New_List);
|
||||
|
||||
@ -1660,7 +1654,7 @@ package body Ch9 is
|
||||
if Ada_Version = Ada_83 then
|
||||
Error_Msg_BC ("OR or ELSE expected");
|
||||
else
|
||||
Error_Msg_BC ("OR or ELSE or THEN ABORT expected");
|
||||
Error_Msg_BC ("OR or ELSE or `THEN ABORT` expected");
|
||||
end if;
|
||||
|
||||
Select_Node := Error;
|
||||
|
Loading…
Reference in New Issue
Block a user