* atree.adb: Set Error_Posted in Error node, helps error recovery.
authorbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Oct 2001 16:15:06 +0000 (16:15 +0000)
committerbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Oct 2001 16:15:06 +0000 (16:15 +0000)
* par-endh.adb (Output_End_Expected): We should also not test
Error_Posted on the Error node, since now it is always set.

* cstand.adb (Create_Standard): Set Etype of Error to Any_Type
to help error recovery. Part of general work on 9407-004.

* par.adb: Add ??? for misuse of error

* sem_res.adb:
(Resolve): Defend against Error, fixes 9407-003.
(Resolve_Discrete_Subtype_Indication): Defend against Error.

* sinfo.ads (N_Error): Now has Etype field (which will be set
to Any_Type to help error recovery).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46077 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/atree.adb
gcc/ada/cstand.adb
gcc/ada/par-endh.adb
gcc/ada/par.adb
gcc/ada/sem_res.adb
gcc/ada/sinfo.ads

index 013a8f2..8801866 100644 (file)
@@ -1,3 +1,22 @@
+2001-10-08  Robert Dewar <dewar@gnat.com>
+
+       * atree.adb: Set Error_Posted in Error node, helps error recovery.
+       
+       * par-endh.adb (Output_End_Expected): We should also not test 
+       Error_Posted on the Error node, since now it is always set.
+       
+       * cstand.adb (Create_Standard): Set Etype of Error to Any_Type 
+       to help error recovery. Part of general work on 9407-004.
+       
+       * par.adb: Add ??? for misuse of error
+       
+       * sem_res.adb:
+       (Resolve): Defend against Error, fixes 9407-003.
+       (Resolve_Discrete_Subtype_Indication): Defend against Error.
+       
+       * sinfo.ads (N_Error): Now has Etype field (which will be set 
+       to Any_Type to help error recovery).
+
 2001-10-08  Richard Kenner (kenner@gnat.com)
 
        * misc.c (gnat_expand_expr, case UNCHECKED_CONVERT_EXPR):
index d7b1af1..7bfff10 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.205 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
 --                                                                          --
@@ -842,13 +842,17 @@ package body Atree is
       Dummy : Node_Id;
 
    begin
-      --  Allocate Empty and Error nodes
+      --  Allocate Empty node
 
       Dummy := New_Node (N_Empty, No_Location);
       Set_Name1 (Empty, No_Name);
+
+      --  Allocate Error node, and set Error_Posted, since we certainly
+      --  only generate an Error node if we do post some kind of error!
+
       Dummy := New_Node (N_Error, No_Location);
       Set_Name1 (Error, Error_Name);
-
+      Set_Error_Posted (Error, True);
    end Initialize;
 
    --------------------------
index 5f167fb..5ca383d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.213 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
 --                                                                          --
@@ -1216,6 +1216,9 @@ package body CStand is
       Last_Standard_Node_Id := Last_Node_Id;
       Last_Standard_List_Id := Last_List_Id;
 
+      --  The Error node has an Etype of Any_Type to help error recovery
+
+      Set_Etype (Error, Any_Type);
    end Create_Standard;
 
    ------------------------------------
index fa5b8c2..dfbe46c 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.61 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
 --                                                                          --
@@ -791,7 +791,7 @@ package body Endh is
 
       --  Suppress message if error was posted on opening label
 
-      if Present (Error_Msg_Node_1)
+      if Error_Msg_Node_1 > Empty_Or_Error
         and then Error_Posted (Error_Msg_Node_1)
       then
          return;
index f45a83b..958a8a7 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.126 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
 --                                                                          --
@@ -396,6 +396,7 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
       --  field references an N_Defining_Program_Unit_Name node for the name.
       --  For cases other than LOOP or BEGIN, the Label field is set to Error,
       --  indicating that it is an error to have a label on the end line.
+      --  (this is really a misuse of Error since there is no Error ???)
 
       Decl : List_Id;
       --  Points to the list of declarations (i.e. the declarative part)
index 641b120..ae2b97c 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.717 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
 --                                                                          --
@@ -1327,6 +1327,10 @@ package body Sem_Res is
    --  Start of processing for Resolve
 
    begin
+      if N = Error then
+         return;
+      end if;
+
       --  Access attribute on remote subprogram cannot be used for
       --  a non-remote access-to-subprogram type.
 
@@ -3496,6 +3500,11 @@ package body Sem_Res is
 
       else
          R := Range_Expression (Constraint (N));
+
+         if R = Error then
+            return;
+         end if;
+
          Analyze (R);
 
          if Base_Type (S) /= Base_Type (Typ) then
index 335f9fa..d6eca70 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                            $Revision: 1.430 $
+--                            $Revision: 1.1 $
 --                                                                          --
 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
 --                                                                          --
@@ -6210,18 +6210,23 @@ package Sinfo is
    -- Empty --
    -----------
 
-   --  N_Empty
-   --  Chars (Name1) is set to No_Name
    --  Used as the contents of the Nkind field of the dummy Empty node
    --  and in some other situations to indicate an uninitialized value.
 
+   --  N_Empty
+   --  Chars (Name1) is set to No_Name
+
    -----------
    -- Error --
    -----------
 
+   --  Used as the contents of the Nkind field of the dummy Error node.
+   --  Has an Etype field, which gets set to Any_Type later on, to help
+   --  error recovery (Error_Posted is also set in the Error node).
+
    --  N_Error
    --  Chars (Name1) is set to Error_Name
-   --  Used as the contents of the Nkind field of the dummy Error node
+   --  Etype (Node5-Sem)
 
    --------------------------
    -- Node Type Definition --
@@ -6248,10 +6253,12 @@ package Sinfo is
 
       --  N_Has_Chars
       N_Empty,
-      N_Error,
       N_Pragma,
       N_Pragma_Argument_Association,
 
+      --  N_Has_Etype
+      N_Error,
+
       --  N_Entity, N_Has_Etype, N_Has_Chars
       N_Defining_Character_Literal,
       N_Defining_Identifier,
@@ -6587,7 +6594,7 @@ package Sinfo is
    --  Warning: DOES NOT INCLUDE N_Freeze_Entity!
 
    subtype N_Has_Etype is Node_Kind range
-     N_Defining_Character_Literal ..
+     N_Error ..
      N_Subtype_Indication;
 
    subtype N_Later_Decl_Item is Node_Kind range