From af1a7c88790c042e3bf59ae3863f197b397fd561 Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Wed, 6 Jun 2007 12:40:24 +0200 Subject: [PATCH] par-ch4.adb: (P_Name): Recover from literal used as name 2007-04-20 Robert Dewar * par-ch4.adb: (P_Name): Recover from literal used as name From-SVN: r125440 --- gcc/ada/par-ch4.adb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb index 220c0656eb5..074e4dba3fe 100644 --- a/gcc/ada/par-ch4.adb +++ b/gcc/ada/par-ch4.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -190,9 +190,24 @@ package body Ch4 is Attr_Name : Name_Id := No_Name; -- kill junk warning begin + -- Case of not a name + if Token not in Token_Class_Name then - Error_Msg_AP ("name expected"); - raise Error_Resync; + + -- If it looks like start of expression, complain and scan expression + + if Token in Token_Class_Literal + or else Token = Tok_Left_Paren + then + Error_Msg_SC ("name expected"); + return P_Expression; + + -- Otherwise some other junk, not much we can do + + else + Error_Msg_AP ("name expected"); + raise Error_Resync; + end if; end if; -- Loop through designators in qualified name @@ -1555,7 +1570,6 @@ package body Ch4 is else return Node1; end if; - end P_Expression; -- This function is identical to the normal P_Expression, except that it -- 2.30.2