function Check_For_Warning (N : Node_Id) return Traverse_Result is
Loc : constant Source_Ptr := Sloc (N);
- E : Error_Msg_Id;
function To_Be_Removed (E : Error_Msg_Id) return Boolean;
-- Returns True for a message that is to be removed. Also adjusts
-- warning count appropriately.
+ procedure Remove_Errors is new
+ Filter_And_Delete_Errors (To_Be_Removed);
+
-------------------
-- To_Be_Removed --
-------------------
-- Start of processing for Check_For_Warnings
begin
- -- Remove the first messages from the error chain.
- -- ??? Why not delete them like the others?
-
- while To_Be_Removed (First_Error_Msg) loop
- Decrease_Error_Msg_Count (Errors.Table (First_Error_Msg));
- First_Error_Msg := Errors.Table (First_Error_Msg).Next;
- end loop;
-
- if First_Error_Msg = No_Error_Msg then
- Last_Error_Msg := No_Error_Msg;
- end if;
-
- E := First_Error_Msg;
- while E /= No_Error_Msg loop
- while To_Be_Removed (Errors.Table (E).Next) loop
- Delete_Error_Msg (Errors.Table (E).Next);
-
- Errors.Table (E).Next :=
- Errors.Table (Errors.Table (E).Next).Next;
-
- if Errors.Table (E).Next = No_Error_Msg then
- Last_Error_Msg := E;
- end if;
- end loop;
-
- E := Errors.Table (E).Next;
- end loop;
+ Remove_Errors;
-- Warnings may have been posted on subexpressions of original tree
-- where the expression is parenthesized, an attempt is made to include
-- the parentheses (i.e. to return the location of the final paren).
- procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr)
- renames Erroutc.Purge_Messages;
+ procedure Delete_Error_Msgs_In_Range (From : Source_Ptr; To : Source_Ptr)
+ renames Erroutc.Delete_Error_Msgs_In_Range;
-- All error messages whose location is in the range From .. To (not
-- including the end points) will be deleted from the error listing.
end if;
end Debug_Output;
+ ------------------------------
+ -- Filter_And_Delete_Errors --
+ ------------------------------
+
+ procedure Filter_And_Delete_Errors is
+ E : Error_Msg_Id;
+ begin
+ E := First_Error_Msg;
+ while E /= No_Error_Msg loop
+ if Filter (E) then
+ Delete_Error_Msg (E);
+ end if;
+
+ E := Errors.Table (E).Next;
+ end loop;
+ end Filter_And_Delete_Errors;
+
----------------------
-- Delete_Error_Msg --
----------------------
end if;
end Delete_Error_Msg;
+ --------------------------------
+ -- Delete_Error_Msgs_In_Range --
+ --------------------------------
+
+ procedure Delete_Error_Msgs_In_Range (From : Source_Ptr; To : Source_Ptr) is
+
+ function Error_in_Range (E : Error_Msg_Id) return Boolean;
+ -- Returns True for a message that is to be purged. Also adjusts
+ -- error counts appropriately.
+
+ procedure Delete_Errors is new Filter_And_Delete_Errors (Error_in_Range);
+
+ --------------------
+ -- Error_in_Range --
+ --------------------
+
+ function Error_in_Range (E : Error_Msg_Id) return Boolean
+ is (E /= No_Error_Msg
+ and then Errors.Table (E).Sptr.Ptr > From
+ and then Errors.Table (E).Sptr.Ptr < To);
+
+ -- Start of processing for Delete_Error_Msgs_In_Range
+
+ begin
+ Delete_Errors;
+ end Delete_Error_Msgs_In_Range;
+
-----------
-- dedit --
-----------
end loop;
end Prescan_Message;
- --------------------
- -- Purge_Messages --
- --------------------
-
- procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr) is
- E : Error_Msg_Id;
-
- function To_Be_Purged (E : Error_Msg_Id) return Boolean;
- -- Returns True for a message that is to be purged. Also adjusts
- -- error counts appropriately.
-
- ------------------
- -- To_Be_Purged --
- ------------------
-
- function To_Be_Purged (E : Error_Msg_Id) return Boolean is
- begin
- if E /= No_Error_Msg
- and then Errors.Table (E).Sptr.Ptr > From
- and then Errors.Table (E).Sptr.Ptr < To
- then
- return True;
-
- else
- return False;
- end if;
- end To_Be_Purged;
-
- -- Start of processing for Purge_Messages
-
- begin
- -- Remove the first messages from the error chain.
- -- ??? Why not delete them like the others?
-
- while To_Be_Purged (First_Error_Msg) loop
- Decrease_Error_Msg_Count (Errors.Table (First_Error_Msg));
- First_Error_Msg := Errors.Table (First_Error_Msg).Next;
- end loop;
-
- E := First_Error_Msg;
- while E /= No_Error_Msg loop
- while To_Be_Purged (Errors.Table (E).Next) loop
- Delete_Error_Msg (Errors.Table (E).Next);
-
- Errors.Table (E).Next :=
- Errors.Table (Errors.Table (E).Next).Next;
- end loop;
-
- E := Errors.Table (E).Next;
- end loop;
- end Purge_Messages;
-
----------------
-- Same_Error --
----------------
procedure Delete_Error_Msg (E : Error_Msg_Id);
-- Delete an error msg if not already deleted and adjust message count
- procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr);
+ procedure Delete_Error_Msgs_In_Range (From : Source_Ptr; To : Source_Ptr);
-- All error messages whose location is in the range From .. To (not
- -- including the end points) will be deleted from the error listing.
+ -- including the end points) will be marked as deleted in the error
+ -- listing.
+
+ generic
+ with function Filter (E : Error_Msg_Id) return Boolean is <>;
+ procedure Filter_And_Delete_Errors;
+ pragma Inline (Filter_And_Delete_Errors);
+ -- Iterate over all of the errors in the error chain and mark all messages
+ -- as deleted if they match the Filter.
function Same_Error (M1, M2 : Error_Msg_Id) return Boolean;
-- See if two messages have the same text. Returns true if the text of the
-- can cause a lot of havoc, and it is better not to dump these
-- cascaded messages on the user.
- Purge_Messages (Get_Location (Missing_Begin_Msg), Prev_Token_Ptr);
+ Delete_Error_Msgs_In_Range
+ (Get_Location (Missing_Begin_Msg), Prev_Token_Ptr);
end if;
end Missing_Begin;