[Ada] Better diagnostic for new language features
gcc/ada/ * par-ch12.adb (P_Formal_Derived_Type_Definition): Complain about formal type with aspect specification, which only become legal in Ada 2020. * par-ch9.adb (P_Protected_Operation_Declaration_Opt): Reuse Error_Msg_Ada_2005_Extension. (P_Entry_Declaration): Likewise. * scng.adb (Scan): Improve diagnostics for target_name; emit error, but otherwise continue in earlier than Ada 2020 modes.
This commit is contained in:
parent
11ad366da5
commit
3838145371
@ -949,20 +949,21 @@ package body Ch12 is
|
||||
|
||||
if Token = Tok_With then
|
||||
|
||||
if Ada_Version >= Ada_2020 and not Next_Token_Is (Tok_Private) then
|
||||
|
||||
if Next_Token_Is (Tok_Private) then
|
||||
Scan; -- past WITH
|
||||
Set_Private_Present (Def_Node, True);
|
||||
T_Private;
|
||||
else
|
||||
-- Formal type has aspect specifications, parsed later.
|
||||
-- Otherwise this is a formal derived type. Note that it may
|
||||
-- also include later aspect specifications, as in:
|
||||
|
||||
-- type DT is new T with private with atomic;
|
||||
-- type DT is new T with private with Atomic;
|
||||
|
||||
Error_Msg_Ada_2020_Feature
|
||||
("formal type with aspect specification", Token_Ptr);
|
||||
|
||||
return Def_Node;
|
||||
|
||||
else
|
||||
Scan; -- past WITH
|
||||
Set_Private_Present (Def_Node, True);
|
||||
T_Private;
|
||||
end if;
|
||||
|
||||
elsif Token = Tok_Tagged then
|
||||
|
@ -752,8 +752,7 @@ package body Ch9 is
|
||||
|
||||
if Is_Overriding or else Not_Overriding then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
Error_Msg_Ada_2005_Extension ("overriding indicator");
|
||||
|
||||
elsif Token = Tok_Entry then
|
||||
Decl := P_Entry_Declaration;
|
||||
@ -962,9 +961,7 @@ package body Ch9 is
|
||||
|
||||
if Is_Overriding or else Not_Overriding then
|
||||
if Ada_Version < Ada_2005 then
|
||||
Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
|
||||
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
|
||||
|
||||
Error_Msg_Ada_2005_Extension ("overriding indicator");
|
||||
elsif Token /= Tok_Entry then
|
||||
Error_Msg_SC -- CODEFIX
|
||||
("ENTRY expected!");
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
with Atree; use Atree;
|
||||
with Csets; use Csets;
|
||||
with Errout; use Errout;
|
||||
with Hostparm; use Hostparm;
|
||||
with Namet; use Namet;
|
||||
with Opt; use Opt;
|
||||
@ -1299,19 +1300,15 @@ package body Scng is
|
||||
return;
|
||||
end if;
|
||||
|
||||
-- AI12-0125-03 : @ is target_name
|
||||
|
||||
when '@' =>
|
||||
if Ada_Version < Ada_2020 then
|
||||
Error_Msg ("target_name is an Ada 202x feature", Scan_Ptr);
|
||||
Scan_Ptr := Scan_Ptr + 1;
|
||||
Error_Msg_Ada_2020_Feature ("target name", Token_Ptr);
|
||||
|
||||
else
|
||||
-- AI12-0125-03 : @ is target_name
|
||||
|
||||
Accumulate_Checksum ('@');
|
||||
Scan_Ptr := Scan_Ptr + 1;
|
||||
Token := Tok_At_Sign;
|
||||
return;
|
||||
end if;
|
||||
Accumulate_Checksum ('@');
|
||||
Scan_Ptr := Scan_Ptr + 1;
|
||||
Token := Tok_At_Sign;
|
||||
return;
|
||||
|
||||
-- Asterisk (can be multiplication operator or double asterisk which
|
||||
-- is the exponentiation compound delimiter).
|
||||
|
Loading…
Reference in New Issue
Block a user