diff mbox series

[Ada] Check token to be "access", reject it if not

Message ID 20220517082728.GA1087423@adacore.com
State New
Headers show
Series [Ada] Check token to be "access", reject it if not | expand

Commit Message

Pierre-Marie de Rodat May 17, 2022, 8:27 a.m. UTC
The parser skips the token without verifying it is indeed "access".  So
any token is accepted.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

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

Patch

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
@@ -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;