[Ada] Check token to be "access", reject it if not
authorEtienne Servais <servais@adacore.com>
Wed, 16 Mar 2022 16:48:22 +0000 (17:48 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:40 +0000 (08:25 +0000)
The parser skips the token without verifying it is indeed "access".  So
any token is accepted.

gcc/ada/

* par-ch3.adb (P_Access_Type_Definition): Outputs an error if
token is not "access".

gcc/ada/par-ch3.adb

index 08ffd7b..d7d1255 100644 (file)
@@ -4205,7 +4205,15 @@ package body Ch3 is
          --  second null exclusion is present in the access type definition.
 
          Not_Null_Present := P_Null_Exclusion; --  Ada 2005 (AI-231)
+
+         if Token /= Tok_Access then
+            Error_Msg
+              ("ACCESS expected",
+               Token_Ptr);
+         end if;
+
          Scan; -- past ACCESS
+
          Not_Null_Subtype_Loc := Token_Ptr;
          Not_Null_Subtype := P_Null_Exclusion; --  Might also appear
       end if;