From d46888e96a5b5964371116002f3bd696846731c2 Mon Sep 17 00:00:00 2001 From: charlet Date: Tue, 14 Aug 2007 08:40:24 +0000 Subject: [PATCH] 2007-08-14 Robert Dewar Ed Schonberg * par.ads, par.adb: Improve handling of extra right parens. (Par): Remove flag From_Limited_With_Clause. * par-util.adb, par-ch3.adb: Improve error recovery for bad constraint Improve handling of extra right parens. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127423 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/par-ch3.adb | 30 ++++++++++++++++-------------- gcc/ada/par-util.adb | 29 +++++++++++++---------------- gcc/ada/par.adb | 11 +++++------ gcc/ada/par.ads | 9 +++------ 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb index 54c5149..53b3c35 100644 --- a/gcc/ada/par-ch3.adb +++ b/gcc/ada/par-ch3.adb @@ -61,15 +61,14 @@ package body Ch3 is Done : out Boolean; In_Spec : Boolean); -- Scans out a single declarative item, or, in the case of a declaration - -- with a list of identifiers, a list of declarations, one for each of - -- the identifiers in the list. The declaration or declarations scanned - -- are appended to the given list. Done indicates whether or not there - -- may be additional declarative items to scan. If Done is True, then - -- a decision has been made that there are no more items to scan. If - -- Done is False, then there may be additional declarations to scan. - -- In_Spec is true if we are scanning a package declaration, and is used - -- to generate an appropriate message if a statement is encountered in - -- such a context. + -- with a list of identifiers, a list of declarations, one for each of the + -- identifiers in the list. The declaration or declarations scanned are + -- appended to the given list. Done indicates whether or not there may be + -- additional declarative items to scan. If Done is True, then a decision + -- has been made that there are no more items to scan. If Done is False, + -- then there may be additional declarations to scan. In_Spec is true if + -- we are scanning a package declaration, and is used to generate an + -- appropriate message if a statement is encountered in such a context. procedure P_Identifier_Declarations (Decls : List_Id; @@ -2410,7 +2409,7 @@ package body Ch3 is begin Constraint_Node := New_Node (N_Digits_Constraint, Token_Ptr); Scan; -- past DIGITS - Expr_Node := P_Expression_No_Right_Paren; + Expr_Node := P_Expression; Check_Simple_Expression_In_Ada_83 (Expr_Node); Set_Digits_Expression (Constraint_Node, Expr_Node); @@ -2442,7 +2441,7 @@ package body Ch3 is begin Constraint_Node := New_Node (N_Delta_Constraint, Token_Ptr); Scan; -- past DELTA - Expr_Node := P_Expression_No_Right_Paren; + Expr_Node := P_Expression; Check_Simple_Expression_In_Ada_83 (Expr_Node); Set_Delta_Expression (Constraint_Node, Expr_Node); @@ -3505,7 +3504,8 @@ package body Ch3 is else begin - Expr_Node := No_Right_Paren (P_Expression_Or_Range_Attribute); + Expr_Node := P_Expression_Or_Range_Attribute; + Check_No_Right_Paren; if Token = Tok_Colon and then Nkind (Expr_Node) = N_Identifier @@ -3602,7 +3602,7 @@ package body Ch3 is if Abstract_Present then Error_Msg_SP ("ABSTRACT not allowed in interface type definition " & - "('R'M' 3.9.4(2/2))"); + "(RM 3.9.4(2/2))"); end if; Scan; -- past INTERFACE @@ -3983,7 +3983,9 @@ package body Ch3 is Scan_State : Saved_Scan_State; begin - if Style_Check then Style.Check_Indentation; end if; + if Style_Check then + Style.Check_Indentation; + end if; case Token is diff --git a/gcc/ada/par-util.adb b/gcc/ada/par-util.adb index 0dd7f0b..2971f56 100644 --- a/gcc/ada/par-util.adb +++ b/gcc/ada/par-util.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2004, 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- -- @@ -176,6 +176,18 @@ package body Util is end if; end Check_Misspelling_Of; + -------------------------- + -- Check_No_Right_Paren -- + -------------------------- + + procedure Check_No_Right_Paren is + begin + if Token = Tok_Right_Paren then + Error_Msg_SC ("unexpected right parenthesis"); + Scan; -- past unexpected right paren + end if; + end Check_No_Right_Paren; + ----------------------------- -- Check_Simple_Expression -- ----------------------------- @@ -587,21 +599,6 @@ package body Util is end if; end No_Constraint; - -------------------- - -- No_Right_Paren -- - -------------------- - - function No_Right_Paren (Expr : Node_Id) return Node_Id is - begin - if Token = Tok_Right_Paren then - Error_Msg_SC ("unexpected right parenthesis"); - Resync_Expression; - return Error; - else - return Expr; - end if; - end No_Right_Paren; - --------------------- -- Pop_Scope_Stack -- --------------------- diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index f33d8ad..370dfbf 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -51,8 +51,7 @@ with Tbuild; use Tbuild; --------- function Par - (Configuration_Pragmas : Boolean; - From_Limited_With : Boolean := False) return List_Id + (Configuration_Pragmas : Boolean) return List_Id is Num_Library_Units : Natural := 0; -- Count number of units parsed (relevant only in syntax check only mode, @@ -1042,6 +1041,10 @@ is -- it is returned unchanged. Otherwise an error message is issued -- and Error is returned. + procedure Check_No_Right_Paren; + -- Called to check that the current token is not a right paren. If it + -- is, then an error is given, and the right parenthesis is scanned out. + function Comma_Present return Boolean; -- Used in comma delimited lists to determine if a comma is present, or -- can reasonably be assumed to have been present (an error message is @@ -1089,10 +1092,6 @@ is -- parameter. If a constraint is present, an error message is posted, -- and the constraint is scanned and discarded. - function No_Right_Paren (Expr : Node_Id) return Node_Id; - -- Function to check for no right paren at end of expression, returns - -- its argument if no right paren, else flags paren and returns Error. - procedure Push_Scope_Stack; pragma Inline (Push_Scope_Stack); -- Push a new entry onto the scope stack. Scope.Last (the stack pointer) diff --git a/gcc/ada/par.ads b/gcc/ada/par.ads index f610ef0..5dd8a2b 100644 --- a/gcc/ada/par.ads +++ b/gcc/ada/par.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2005, 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- -- @@ -30,17 +30,14 @@ with Types; use Types; function Par - (Configuration_Pragmas : Boolean; - From_Limited_With : Boolean := False) return List_Id; + (Configuration_Pragmas : Boolean) return List_Id; -- Top level parsing routine. There are two cases: -- -- If Configuration_Pragmas is False, Par parses a compilation unit in the -- current source file and sets the Cunit, Cunit_Entity and Unit_Name fields -- of the units table entry for Current_Source_Unit. On return the parse tree -- is complete, and decorated with any required implicit label declarations. --- The value returned in this case is always No_List. If From_Limited_With is --- True, we are parsing a compilation unit found in a limited-with clause (Ada --- 2005, AI-50217) +-- The value returned in this case is always No_List. -- -- If Configuration_Pragmas is True, Par parses a list of configuration -- pragmas from the current source file, and returns the list of pragmas. -- 2.7.4