(E_Id : Error_Msg_Id) return Sub_Diagnostic_Type;
function Get_Warning_Kind (E_Msg : Error_Msg_Object) return Diagnostic_Kind
- is (if E_Msg.Info then Info_Warning
- elsif E_Msg.Warn_Chr = "* " then Restriction_Warning
+ is (if E_Msg.Warn_Chr = "* " then Restriction_Warning
elsif E_Msg.Warn_Chr = "? " then Default_Warning
elsif E_Msg.Warn_Chr = " " then Tagless_Warning
else Warning);
-- printer added the warning switch label but treated the message as
-- an info message.
+ function Get_Diagnostics_Kind (E_Msg : Error_Msg_Object)
+ return Diagnostic_Kind
+ is (if E_Msg.Warn then Get_Warning_Kind (E_Msg)
+ elsif E_Msg.Style then Style
+ elsif E_Msg.Info then Info
+ else Error);
+
-----------------------------------
-- Convert_Errors_To_Diagnostics --
-----------------------------------
-- shall be printed with the same kind token as the main diagnostic.
D.Kind := Continuation;
- declare
- L : Labeled_Span_Type;
- begin
- if E_Msg.Insertion_Sloc /= No_Location then
- L.Span := To_Span (E_Msg.Insertion_Sloc);
- else
- L.Span := E_Msg.Sptr;
- end if;
-
- L.Is_Primary := True;
- Add_Location (D, L);
- end;
+ Add_Location (D,
+ Primary_Labeled_Span
+ (if E_Msg.Insertion_Sloc /= No_Location
+ then To_Span (E_Msg.Insertion_Sloc)
+ else E_Msg.Sptr));
if E_Msg.Optr.Ptr /= E_Msg.Sptr.Ptr then
- declare
- L : Labeled_Span_Type;
- begin
- L.Span := E_Msg.Optr;
- L.Is_Primary := False;
- Add_Location (D, L);
- end;
+ Add_Location (D, Secondary_Labeled_Span (E_Msg.Optr));
end if;
return D;
begin
D.Message := E_Msg.Text;
- if E_Msg.Warn then
- D.Kind := Get_Warning_Kind (E_Msg);
- D.Switch := Get_Switch_Id (E_Msg);
- elsif E_Msg.Style then
- D.Kind := Style;
- D.Switch := Get_Switch_Id (E_Msg);
- elsif E_Msg.Info then
- D.Kind := Info;
+ D.Kind := Get_Diagnostics_Kind (E_Msg);
+
+ if E_Msg.Warn or E_Msg.Style or E_Msg.Info then
D.Switch := Get_Switch_Id (E_Msg);
- else
- D.Kind := Error;
end if;
D.Warn_Err := E_Msg.Warn_Err;
-- Convert the primary location
- declare
- L : Labeled_Span_Type;
- begin
- L.Span := E_Msg.Sptr;
- L.Is_Primary := True;
- Add_Location (D, L);
- end;
+ Add_Location (D, Primary_Labeled_Span (E_Msg.Sptr));
-- Convert the secondary location if it is different from the primary
if E_Msg.Optr.Ptr /= E_Msg.Sptr.Ptr then
- declare
- L : Labeled_Span_Type;
- begin
- L.Span := E_Msg.Optr;
- L.Is_Primary := False;
- Add_Location (D, L);
- end;
+ Add_Location (D, Secondary_Labeled_Span (E_Msg.Optr));
end if;
E_Next_Id := Errors.Table (E_Id).Next;
Diag : Diagnostic_Type)
return Boolean
is
- Sub_Loc : constant Labeled_Span_Type :=
- Get_Primary_Labeled_Span (Sub_Diag.Locations);
-
- Diag_Loc : constant Labeled_Span_Type :=
- Get_Primary_Labeled_Span (Diag.Locations);
+ Sub_Loc : constant Labeled_Span_Type := Primary_Location (Sub_Diag);
+ Diag_Loc : constant Labeled_Span_Type := Primary_Location (Diag);
function Has_Multiple_Files (Spans : Labeled_Span_List) return Boolean;
Diag : Diagnostic_Type)
return Boolean
is
- Sub_Loc : constant Labeled_Span_Type :=
- Get_Primary_Labeled_Span (Sub_Diag.Locations);
-
- Diag_Loc : constant Labeled_Span_Type :=
- Get_Primary_Labeled_Span (Diag.Locations);
+ Sub_Loc : constant Labeled_Span_Type := Primary_Location (Sub_Diag);
+ Diag_Loc : constant Labeled_Span_Type := Primary_Location (Diag);
begin
return Sub_Loc /= No_Labeled_Span
and then Diag_Loc /= No_Labeled_Span
when Warning | Restriction_Warning | Default_Warning |
Tagless_Warning => "warning",
when Style => "style",
- when Info | Info_Warning => "info"));
+ when Info => "info"));
------------------------------
-- Get_Primary_Labeled_Span --
if Warning_Doc_Switch
and then Diag.Kind in Default_Warning
| Info
- | Info_Warning
| Restriction_Warning
| Style
| Warning
elsif Diag.Kind /= Info then
- -- For Default_Warning and Info_Warning
+ -- For Default_Warning
return "[enabled by default]";
end if;
function Primary_Location
(Diagnostic : Sub_Diagnostic_Type) return Labeled_Span_Type
is
- use Labeled_Span_Lists;
- Loc : Labeled_Span_Type;
-
- It : Iterator := Iterate (Diagnostic.Locations);
begin
- while Has_Next (It) loop
- Next (It, Loc);
- if Loc.Is_Primary then
- return Loc;
- end if;
- end loop;
-
- return (others => <>);
+ return Get_Primary_Labeled_Span (Diagnostic.Locations);
end Primary_Location;
------------------