2005-11-14 Robert Dewar <dewar@adacore.com> * a-secain.adb, a-slcain.adb, a-shcain.adb, a-chtgke.ads, a-chtgke.adb, a-stwiha.adb, a-strhas.adb, a-chzla1.ads, a-chzla9.ads, a-stzbou.adb, a-stzbou.ads, a-stzfix.adb, a-stzhas.adb, a-stzmap.adb, a-stzmap.ads, a-stzsea.adb, a-stzsea.ads, a-stzsup.adb, a-stzsup.ads, a-stzunb.adb, a-stzunb.ads, a-szuzha.adb, a-szuzha.ads, a-szuzti.adb, a-szuzti.ads, a-ztcoau.adb, a-ztcoau.ads, a-ztcoio.adb, a-ztcstr.adb, a-ztcstr.ads, a-ztdeau.adb, a-ztdeau.ads, a-ztdeio.adb, a-ztdeio.ads, a-ztedit.adb, a-ztedit.ads, a-ztenau.ads, a-ztenio.adb, a-ztenio.ads, a-ztexio.adb, a-ztexio.ads, a-ztfiio.adb, a-ztfiio.ads, a-ztflau.adb, a-ztflau.ads, a-ztflio.adb, a-ztflio.ads, a-ztgeau.adb, a-ztgeau.ads, a-ztinau.adb, a-ztinau.ads, a-ztinio.adb, a-ztmoau.ads, a-ztmoio.adb, a-ztmoio.ads, a-zttest.adb, g-enblsp-vms-alpha.adb, g-enblsp-vms-alpha.adb, g-enblsp-vms-ia64.adb, g-enblsp-vms-ia64.adb, system-linux-hppa.ads, a-chacon.adb, a-chacon.ads, a-wichun.adb, a-wichun.ads, a-zchuni.adb, a-zchuni.ads, g-trasym-vms-alpha.adb, g-trasym-vms-ia64.adb, system-hpux-ia64.ads, g-soccon-unixware.ads, g-soliop-unixware.ads, g-soccon-interix.ads, g-soliop-solaris.ads, g-eacodu-vms.adb, g-expect-vms.adb, g-socthi-vms.adb, g-soliop-mingw.ads, a-intnam-unixware.ads, a-intnam-lynxos.ads, a-intnam-tru64.ads, a-intnam-aix.ads, a-intnam-linux.ads, a-intnam-linux.ads, a-intnam-dummy.ads, a-numaux-libc-x86.ads, a-intnam-interix.ads, a-intnam-solaris.ads, a-calend-vms.adb, a-calend-vms.ads, a-intnam-vms.ads, a-calend-mingw.adb, a-intnam-mingw.ads, a-intnam-vxworks.ads, a-numaux-vxworks.ads, system-unixware.ads, system-linux-ia64.ads, a-intnam-freebsd.ads, system-freebsd-x86.ads, system-lynxos-ppc.ads, system-linux-x86_64.ads, a-stunha.adb, a-cgaaso.ads, a-cgaaso.adb, a-chtgop.adb, a-cgcaso.adb, a-cgarso.adb, a-cohata.ads, a-crbtgk.adb, a-crbltr.ads, a-coprnu.adb, a-rbtgso.adb, a-intnam-darwin.ads, system-darwin-ppc.ads, gprmake.adb, makegpr.ads, system-tru64.ads, system-aix.ads, system-solaris-x86.ads, system-irix-o32.ads, s-interr-sigaction.adb, system-irix-n32.ads, s-parame-mingw.adb, system-hpux.ads, s-traceb-hpux.adb, system-linux-x86.ads, s-inmaop-dummy.adb, system-os2.ads, system-interix.ads, system-solaris-sparc.ads, system-solaris-sparcv9.ads, s-inmaop-vms.adb, s-mastop-vms.adb, expander.adb, expander.ads, s-gloloc-mingw.adb, system-mingw.ads, system-vms-zcx.ads, s-osinte-fsu.adb, s-traceb-mastop.adb, a-exextr.adb, a-exstat.adb, a-filico.ads, a-finali.ads, a-interr.ads, a-intsig.adb, a-intsig.ads, a-except.ads, a-numaux-x86.ads, a-astaco.adb, a-calend.adb, a-calend.ads, a-chahan.adb, a-chahan.ads, a-chlat9.ads, a-colien.adb, a-colien.ads, a-colire.adb, a-colire.ads, a-comlin.adb, a-comlin.ads, a-cwila1.ads, a-cwila9.ads, a-elchha.adb, a-decima.adb, a-decima.ads, a-diocst.ads, a-direio.adb, a-direio.ads, a-excach.adb, a-excach.adb, a-exctra.ads, ali-util.adb, a-ngcefu.adb, a-ngcoty.adb, a-ngcoty.ads, a-nudira.adb, a-nudira.ads, a-nuflra.adb, a-numaux.ads, a-reatim.ads, a-sequio.adb, a-sequio.ads, a-siocst.ads, a-ssicst.ads, a-stmaco.ads, a-storio.adb, a-strbou.adb, a-strbou.ads, a-stream.ads, a-strfix.adb, a-strmap.adb, a-strmap.ads, a-strsea.adb, a-strsea.ads, a-strsup.adb, a-strsup.ads, a-strunb.adb, a-strunb.ads, a-stwibo.adb, a-stwibo.ads, a-stwifi.adb, a-stwima.adb, a-stwima.ads, a-stwise.adb, a-stwise.ads, a-stwisu.adb, a-stwisu.ads, a-stwiun.adb, a-stwiun.ads, a-suteio.adb, a-suteio.ads, a-swmwco.ads, a-swuwti.adb, a-swuwti.ads, a-sytaco.adb, a-sytaco.ads, a-tasatt.adb, a-taside.adb, a-taside.ads, a-teioed.adb, a-textio.adb, a-textio.ads, a-ticoau.adb, a-ticoau.ads, a-ticoio.adb, a-tideau.adb, a-tideio.adb, a-tienau.adb, a-tienio.adb, a-tifiio.adb, a-tiflio.adb, a-tigeau.adb, a-tigeau.ads, a-tiinau.adb, a-tiinio.adb, a-timoau.adb, a-timoio.adb, a-timoio.ads, a-tiocst.ads, a-titest.adb, atree.adb, a-witeio.adb, a-witeio.ads, a-wtcoau.adb, a-wtcoau.ads, a-wtcoio.adb, a-wtcstr.ads, a-wtdeau.adb, a-wtdeio.adb, a-wtedit.adb, a-wtedit.ads, a-wtenau.adb, a-wtenio.adb, a-wtfiio.adb, a-wtflio.adb, a-wtgeau.adb, a-wtinau.adb, a-wtinio.adb, a-wtmoau.adb, a-wtmoio.adb, a-wttest.adb, back_end.adb, bindgen.adb, butil.adb, butil.ads, checks.ads, cio.c, comperr.adb, csets.ads, cstand.adb, debug.ads, elists.ads, errno.c, errout.adb, errout.ads, erroutc.adb, erroutc.ads, errutil.adb, errutil.ads, errutil.ads, err_vars.ads, eval_fat.adb, exp_ch11.adb, exp_ch11.ads, exp_ch2.adb, exp_ch7.ads, exp_imgv.ads, exp_pakd.adb, exp_prag.adb, exp_prag.ads, exp_tss.adb, exp_tss.ads, exp_vfpt.ads, fe.h, fmap.adb, freeze.ads, frontend.adb, frontend.ads, g-arrspl.adb, g-arrspl.ads, g-awk.adb, g-awk.ads, g-boumai.ads, g-calend.adb, g-calend.ads, g-catiio.adb, g-comlin.adb, g-comlin.ads, g-comlin.ads, g-comlin.ads, g-comver.adb, g-crc32.adb, g-crc32.ads, g-ctrl_c.ads, g-curexc.ads, g-debpoo.ads, g-debuti.adb, g-diopit.adb, g-diopit.ads, g-dirope.adb, g-dirope.ads, g-dyntab.adb, g-dyntab.ads, g-excact.adb, g-excact.ads, g-except.ads, g-exctra.adb, g-exctra.ads, g-expect.ads, g-flocon.ads, g-hesorg.ads, g-io.adb, g-locfil.ads, g-md5.adb, g-md5.ads, g-md5.ads, g-moreex.adb, g-signal.ads, g-signal.adb, gnatbind.ads, gnatchop.adb, gnatcmd.adb, gnatfind.adb, gnatlbr.adb, gnatmake.ads, gnatmem.adb, gnatprep.adb, gnatprep.ads, gnatsym.adb, gnatxref.adb, g-os_lib.adb, g-os_lib.ads, g-pehage.adb, g-pehage.ads, gprep.ads, g-regexp.adb, g-regexp.ads, g-regist.adb, g-regist.ads, g-regpat.ads, g-semaph.adb, g-socthi.adb, g-soliop.ads, g-spipat.adb, g-spipat.ads, g-sptabo.ads, g-sptain.ads, g-sptavs.ads, g-string.ads, g-tasloc.adb, g-tasloc.ads, g-trasym.adb, g-trasym.ads, i-fortra.adb, i-fortra.ads, inline.adb, layout.adb, live.adb, make.ads, makeutl.ads, makeutl.adb, mdll-fil.adb, mdll-fil.ads, mdll-utl.ads, memroot.ads, memtrack.adb, mlib.ads, mlib-fil.adb, mlib-fil.ads, mlib-prj.ads, mlib-utl.adb, mlib-utl.ads, nlists.adb, nlists.ads, osint.adb, osint.ads, osint-c.adb, osint-l.adb, osint-l.ads, osint-m.ads, output.adb, par.adb, par.adb, par.ads, par-ch11.adb, par-ch12.adb, par-ch2.adb, par-ch4.adb, par-ch5.adb, par-ch6.adb, par-ch9.adb, par-endh.adb, par-labl.adb, par-load.adb, par-tchk.adb, prep.adb, prepcomp.adb, prepcomp.ads, prj-attr.ads, prj-com.ads, prj-dect.adb, prj-dect.ads, prj-env.ads, prj-err.ads, prj-ext.ads, prj-makr.adb, prj-makr.ads, prj-nmsc.ads, prj-pars.adb, prj-pars.ads, prj-part.ads, prj-pp.ads, prj-proc.ads, prj-strt.adb, prj-strt.ads, prj-tree.adb, prj-util.adb, prj-util.ads, rtsfind.adb, sem.adb, sem.ads, sem_case.adb, sem_case.ads, sem_ch11.adb, sem_ch4.adb, sem_ch6.ads, sem_ch7.ads, sem_dist.ads, sem_elab.ads, sem_elim.ads, sem_eval.ads, sem_intr.ads, sem_maps.adb, sem_maps.ads, sem_maps.ads, sem_res.ads, sem_type.ads, sfn_scan.adb, sfn_scan.ads, s-imgwch.ads, s-imgwiu.adb, s-imgwiu.ads, s-inmaop.ads, sinput.adb, sinput.ads, s-pack03.adb, s-pack03.ads, s-pack05.adb, s-pack05.ads, s-pack06.adb, s-pack06.ads, s-pack07.adb, s-pack07.ads, s-pack09.adb, s-pack09.ads, s-pack10.adb, s-pack10.ads, s-pack11.adb, s-pack11.ads, s-pack12.adb, s-pack12.ads, s-pack13.adb, s-pack13.ads, s-pack14.adb, s-pack14.ads, s-pack15.adb, s-pack15.ads, s-pack17.adb, s-pack17.ads, s-pack18.adb, s-pack18.ads, s-pack19.adb, s-pack19.ads, s-pack20.adb, s-pack20.ads, s-pack21.adb, s-pack21.ads, s-pack22.adb, s-pack22.ads, s-pack23.adb, s-pack23.ads, s-pack24.adb, s-pack24.ads, s-pack25.adb, s-pack25.ads, s-pack26.adb, s-pack26.ads, s-pack27.adb, s-pack27.ads, s-pack28.adb, s-pack28.ads, s-pack29.adb, s-pack29.ads, s-pack30.adb, s-pack30.ads, s-pack31.adb, s-pack31.ads, s-pack33.adb, s-pack33.ads, s-pack34.adb, s-pack34.ads, s-pack35.adb, s-pack35.ads, s-pack36.adb, s-pack36.ads, s-pack37.adb, s-pack37.ads, s-pack38.adb, s-pack38.ads, s-pack39.adb, s-pack39.ads, s-pack40.adb, s-pack40.ads, s-pack41.adb, s-pack41.ads, s-pack42.adb, s-pack42.ads, s-pack43.adb, s-pack43.ads, s-pack44.adb, s-pack44.ads, s-pack45.adb, s-pack45.ads, s-pack46.adb, s-pack46.ads, s-pack47.adb, s-pack47.ads, s-pack48.adb, s-pack48.ads, s-pack49.adb, s-pack49.ads, s-pack50.adb, s-pack50.ads, s-pack51.adb, s-pack51.ads, s-pack52.adb, s-pack52.ads, s-pack53.adb, s-pack53.ads, s-pack54.adb, s-pack54.ads, s-pack55.adb, s-pack55.ads, s-pack56.adb, s-pack56.ads, s-pack57.adb, s-pack57.ads, s-pack58.adb, s-pack58.ads, s-pack59.adb, s-pack59.ads, s-pack60.adb, s-pack60.adb, s-pack60.ads, s-pack61.adb, s-pack61.ads, s-pack62.adb, s-pack62.ads, s-pack63.adb, s-pack63.ads, s-parint.adb, s-parint.adb, s-parint.ads, sprint.ads, s-purexc.ads, s-restri.ads, s-restri.adb, s-scaval.adb, s-scaval.ads, s-secsta.adb, s-secsta.ads, s-sequio.adb, s-sequio.ads, stand.ads, s-tasuti.adb, s-traceb.adb, s-traceb.ads, stringt.adb, stringt.ads, styleg.ads, s-valboo.adb, s-valboo.ads, s-valcha.adb, s-valcha.ads, s-valdec.adb, s-valdec.ads, s-valint.adb, s-valint.ads, s-valint.ads, s-vallld.adb, s-vallld.ads, s-vallli.adb, s-vallli.ads, s-valllu.adb, s-valllu.ads, s-valrea.adb, s-valrea.ads, s-valuns.adb, s-valuns.ads, s-valuti.adb, s-valuti.ads, s-valwch.ads, s-veboop.adb, s-veboop.ads, s-vercon.adb, s-vercon.ads, s-wchcnv.adb, s-wchcnv.ads, s-wchcon.ads, s-wchjis.adb, s-wchjis.ads, s-wchstw.adb, s-wchstw.adb, s-wchstw.ads, s-wchwts.adb, s-wchwts.ads, s-widboo.adb, s-widboo.ads, s-widcha.adb, s-widcha.ads, s-widenu.adb, s-widenu.ads, s-widlli.adb, s-widlli.ads, s-widllu.adb, s-widllu.ads, s-widwch.adb, s-widwch.ads, s-wwdcha.adb, s-wwdcha.ads, s-wwdenu.adb, s-wwdenu.ads, symbols.adb, symbols.ads, table.ads, targparm.adb, targparm.ads, tb-alvms.c, tb-alvxw.c, tbuild.adb, tree_io.ads, treepr.adb, treeprs.adt, ttypef.ads, ttypes.ads, types.adb, uintp.adb, uintp.ads, uname.ads, urealp.ads, usage.ads, validsw.ads, vxaddr2line.adb, widechar.adb, widechar.ads, xeinfo.adb, xnmake.adb, xref_lib.ads, xr_tabls.adb, xr_tabls.ads, xsinfo.adb, xtreeprs.adb, xsnames.adb, vms_conv.ads, vms_conv.adb, a-dirval.ads, a-dirval.adb, a-dirval-mingw.adb, a-direct.ads, a-direct.adb, indepsw.ads, prj-attr-pm.ads, system-linux-ppc.ads, a-numaux-darwin.ads, a-numaux-darwin.adb, a-swuwha.ads, a-stunha.ads: Minor reformatting From-SVN: r107016
755 lines
23 KiB
Ada
755 lines
23 KiB
Ada
------------------------------------------------------------------------------
|
|
-- --
|
|
-- GNAT COMPILER COMPONENTS --
|
|
-- --
|
|
-- E R R U T I L --
|
|
-- --
|
|
-- B o d y --
|
|
-- --
|
|
-- Copyright (C) 1991-2005, 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- --
|
|
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
|
-- for more details. You should have received a copy of the GNU General --
|
|
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
|
-- Boston, MA 02110-1301, USA. --
|
|
-- --
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
|
-- --
|
|
------------------------------------------------------------------------------
|
|
|
|
with Err_Vars; use Err_Vars;
|
|
with Erroutc; use Erroutc;
|
|
with Namet; use Namet;
|
|
with Opt; use Opt;
|
|
with Output; use Output;
|
|
with Scans; use Scans;
|
|
with Sinput; use Sinput;
|
|
|
|
package body Errutil is
|
|
|
|
Errors_Must_Be_Ignored : Boolean := False;
|
|
-- Set to True by procedure Set_Ignore_Errors (True), when calls to
|
|
-- error message procedures should be ignored (when parsing irrelevant
|
|
-- text in sources being preprocessed).
|
|
|
|
-----------------------
|
|
-- Local Subprograms --
|
|
-----------------------
|
|
|
|
procedure Error_Msg_AP (Msg : String);
|
|
-- Output a message just after the previous token
|
|
|
|
procedure Output_Source_Line
|
|
(L : Physical_Line_Number;
|
|
Sfile : Source_File_Index;
|
|
Errs : Boolean;
|
|
Source_Type : String);
|
|
-- Outputs text of source line L, in file S, together with preceding line
|
|
-- number, as described above for Output_Line_Number. The Errs parameter
|
|
-- indicates if there are errors attached to the line, which forces
|
|
-- listing on, even in the presence of pragma List (Off).
|
|
|
|
procedure Set_Msg_Insertion_Column;
|
|
-- Handle column number insertion (@ insertion character)
|
|
|
|
procedure Set_Msg_Text (Text : String; Flag : Source_Ptr);
|
|
-- Add a sequence of characters to the current message. The characters may
|
|
-- be one of the special insertion characters (see documentation in spec).
|
|
-- Flag is the location at which the error is to be posted, which is used
|
|
-- to determine whether or not the # insertion needs a file name. The
|
|
-- variables Msg_Buffer, Msglen, Is_Style_Msg, Is_Warning_Msg, and
|
|
-- Is_Unconditional_Msg are set on return.
|
|
|
|
------------------
|
|
-- Error_Msg_AP --
|
|
------------------
|
|
|
|
procedure Error_Msg_AP (Msg : String) is
|
|
S1 : Source_Ptr;
|
|
C : Character;
|
|
|
|
begin
|
|
-- If we had saved the Scan_Ptr value after scanning the previous
|
|
-- token, then we would have exactly the right place for putting
|
|
-- the flag immediately at hand. However, that would add at least
|
|
-- two instructions to a Scan call *just* to service the possibility
|
|
-- of an Error_Msg_AP call. So instead we reconstruct that value.
|
|
|
|
-- We have two possibilities, start with Prev_Token_Ptr and skip over
|
|
-- the current token, which is made harder by the possibility that this
|
|
-- token may be in error, or start with Token_Ptr and work backwards.
|
|
-- We used to take the second approach, but it's hard because of
|
|
-- comments, and harder still because things that look like comments
|
|
-- can appear inside strings. So now we take the first approach.
|
|
|
|
-- Note: in the case where there is no previous token, Prev_Token_Ptr
|
|
-- is set to Source_First, which is a reasonable position for the
|
|
-- error flag in this situation.
|
|
|
|
S1 := Prev_Token_Ptr;
|
|
C := Source (S1);
|
|
|
|
-- If the previous token is a string literal, we need a special approach
|
|
-- since there may be white space inside the literal and we don't want
|
|
-- to stop on that white space.
|
|
|
|
-- Note that it is not worth worrying about special UTF_32 line
|
|
-- terminator characters in this context, since this is only about
|
|
-- error recovery anyway.
|
|
|
|
if Prev_Token = Tok_String_Literal then
|
|
loop
|
|
S1 := S1 + 1;
|
|
|
|
if Source (S1) = C then
|
|
S1 := S1 + 1;
|
|
exit when Source (S1) /= C;
|
|
elsif Source (S1) in Line_Terminator then
|
|
exit;
|
|
end if;
|
|
end loop;
|
|
|
|
-- Character literal also needs special handling
|
|
|
|
elsif Prev_Token = Tok_Char_Literal then
|
|
S1 := S1 + 3;
|
|
|
|
-- Otherwise we search forward for the end of the current token, marked
|
|
-- by a line terminator, white space, a comment symbol or if we bump
|
|
-- into the following token (i.e. the current token)
|
|
|
|
-- Note that it is not worth worrying about special UTF_32 line
|
|
-- terminator characters in this context, since this is only about
|
|
-- error recovery anyway.
|
|
|
|
else
|
|
while Source (S1) not in Line_Terminator
|
|
and then Source (S1) /= ' '
|
|
and then Source (S1) /= ASCII.HT
|
|
and then (Source (S1) /= '-' or else Source (S1 + 1) /= '-')
|
|
and then S1 /= Token_Ptr
|
|
loop
|
|
S1 := S1 + 1;
|
|
end loop;
|
|
end if;
|
|
|
|
-- S1 is now set to the location for the flag
|
|
|
|
Error_Msg (Msg, S1);
|
|
|
|
end Error_Msg_AP;
|
|
|
|
---------------
|
|
-- Error_Msg --
|
|
---------------
|
|
|
|
procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr) is
|
|
|
|
Next_Msg : Error_Msg_Id;
|
|
-- Pointer to next message at insertion point
|
|
|
|
Prev_Msg : Error_Msg_Id;
|
|
-- Pointer to previous message at insertion point
|
|
|
|
Sptr : Source_Ptr renames Flag_Location;
|
|
-- Corresponds to the Sptr value in the error message object
|
|
|
|
Optr : Source_Ptr renames Flag_Location;
|
|
-- Corresponds to the Optr value in the error message object. Note
|
|
-- that for this usage, Sptr and Optr always have the same value,
|
|
-- since we do not have to worry about generic instantiations.
|
|
|
|
begin
|
|
if Errors_Must_Be_Ignored then
|
|
return;
|
|
end if;
|
|
|
|
if Raise_Exception_On_Error /= 0 then
|
|
raise Error_Msg_Exception;
|
|
end if;
|
|
|
|
Test_Style_Warning_Serious_Msg (Msg);
|
|
Set_Msg_Text (Msg, Sptr);
|
|
|
|
-- Kill continuation if parent message killed
|
|
|
|
if Continuation and Last_Killed then
|
|
return;
|
|
end if;
|
|
|
|
-- Return without doing anything if message is killed and this is not
|
|
-- the first error message. The philosophy is that if we get a weird
|
|
-- error message and we already have had a message, then we hope the
|
|
-- weird message is a junk cascaded message
|
|
|
|
-- Immediate return if warning message and warnings are suppressed.
|
|
-- Note that style messages are not warnings for this purpose.
|
|
|
|
if Is_Warning_Msg and then Warnings_Suppressed (Sptr) then
|
|
Cur_Msg := No_Error_Msg;
|
|
return;
|
|
end if;
|
|
|
|
-- Otherwise build error message object for new message
|
|
|
|
Errors.Increment_Last;
|
|
Cur_Msg := Errors.Last;
|
|
Errors.Table (Cur_Msg).Text := new String'(Msg_Buffer (1 .. Msglen));
|
|
Errors.Table (Cur_Msg).Next := No_Error_Msg;
|
|
Errors.Table (Cur_Msg).Sptr := Sptr;
|
|
Errors.Table (Cur_Msg).Optr := Optr;
|
|
Errors.Table (Cur_Msg).Sfile := Get_Source_File_Index (Sptr);
|
|
Errors.Table (Cur_Msg).Line := Get_Physical_Line_Number (Sptr);
|
|
Errors.Table (Cur_Msg).Col := Get_Column_Number (Sptr);
|
|
Errors.Table (Cur_Msg).Style := Is_Style_Msg;
|
|
Errors.Table (Cur_Msg).Warn := Is_Warning_Msg;
|
|
Errors.Table (Cur_Msg).Serious := Is_Serious_Error;
|
|
Errors.Table (Cur_Msg).Uncond := Is_Unconditional_Msg;
|
|
Errors.Table (Cur_Msg).Msg_Cont := Continuation;
|
|
Errors.Table (Cur_Msg).Deleted := False;
|
|
|
|
Prev_Msg := No_Error_Msg;
|
|
Next_Msg := First_Error_Msg;
|
|
|
|
while Next_Msg /= No_Error_Msg loop
|
|
exit when
|
|
Errors.Table (Cur_Msg).Sfile < Errors.Table (Next_Msg).Sfile;
|
|
|
|
if Errors.Table (Cur_Msg).Sfile = Errors.Table (Next_Msg).Sfile then
|
|
exit when Sptr < Errors.Table (Next_Msg).Sptr;
|
|
end if;
|
|
|
|
Prev_Msg := Next_Msg;
|
|
Next_Msg := Errors.Table (Next_Msg).Next;
|
|
end loop;
|
|
|
|
-- Now we insert the new message in the error chain. The insertion
|
|
-- point for the message is after Prev_Msg and before Next_Msg.
|
|
|
|
-- The possible insertion point for the new message is after Prev_Msg
|
|
-- and before Next_Msg. However, this is where we do a special check
|
|
-- for redundant parsing messages, defined as messages posted on the
|
|
-- same line. The idea here is that probably such messages are junk
|
|
-- from the parser recovering. In full errors mode, we don't do this
|
|
-- deletion, but otherwise such messages are discarded at this stage.
|
|
|
|
if Prev_Msg /= No_Error_Msg
|
|
and then Errors.Table (Prev_Msg).Line =
|
|
Errors.Table (Cur_Msg).Line
|
|
and then Errors.Table (Prev_Msg).Sfile =
|
|
Errors.Table (Cur_Msg).Sfile
|
|
then
|
|
-- Don't delete unconditional messages and at this stage, don't
|
|
-- delete continuation lines (we attempted to delete those earlier
|
|
-- if the parent message was deleted.
|
|
|
|
if not Errors.Table (Cur_Msg).Uncond
|
|
and then not Continuation
|
|
then
|
|
|
|
-- Don't delete if prev msg is warning and new msg is an error.
|
|
-- This is because we don't want a real error masked by a warning.
|
|
-- In all other cases (that is parse errors for the same line that
|
|
-- are not unconditional) we do delete the message. This helps to
|
|
-- avoid junk extra messages from cascaded parsing errors
|
|
|
|
if not (Errors.Table (Prev_Msg).Warn
|
|
or
|
|
Errors.Table (Prev_Msg).Style)
|
|
or else
|
|
(Errors.Table (Cur_Msg).Warn
|
|
or
|
|
Errors.Table (Cur_Msg).Style)
|
|
then
|
|
-- All tests passed, delete the message by simply returning
|
|
-- without any further processing.
|
|
|
|
if not Continuation then
|
|
Last_Killed := True;
|
|
end if;
|
|
|
|
return;
|
|
end if;
|
|
end if;
|
|
end if;
|
|
|
|
-- Come here if message is to be inserted in the error chain
|
|
|
|
if not Continuation then
|
|
Last_Killed := False;
|
|
end if;
|
|
|
|
if Prev_Msg = No_Error_Msg then
|
|
First_Error_Msg := Cur_Msg;
|
|
else
|
|
Errors.Table (Prev_Msg).Next := Cur_Msg;
|
|
end if;
|
|
|
|
Errors.Table (Cur_Msg).Next := Next_Msg;
|
|
|
|
-- Bump appropriate statistics count
|
|
|
|
if Errors.Table (Cur_Msg).Warn or Errors.Table (Cur_Msg).Style then
|
|
Warnings_Detected := Warnings_Detected + 1;
|
|
else
|
|
Total_Errors_Detected := Total_Errors_Detected + 1;
|
|
|
|
if Errors.Table (Cur_Msg).Serious then
|
|
Serious_Errors_Detected := Serious_Errors_Detected + 1;
|
|
end if;
|
|
end if;
|
|
|
|
end Error_Msg;
|
|
|
|
-----------------
|
|
-- Error_Msg_S --
|
|
-----------------
|
|
|
|
procedure Error_Msg_S (Msg : String) is
|
|
begin
|
|
Error_Msg (Msg, Scan_Ptr);
|
|
end Error_Msg_S;
|
|
|
|
------------------
|
|
-- Error_Msg_SC --
|
|
------------------
|
|
|
|
procedure Error_Msg_SC (Msg : String) is
|
|
begin
|
|
-- If we are at end of file, post the flag after the previous token
|
|
|
|
if Token = Tok_EOF then
|
|
Error_Msg_AP (Msg);
|
|
|
|
-- For all other cases the message is posted at the current token
|
|
-- pointer position
|
|
|
|
else
|
|
Error_Msg (Msg, Token_Ptr);
|
|
end if;
|
|
end Error_Msg_SC;
|
|
|
|
------------------
|
|
-- Error_Msg_SP --
|
|
------------------
|
|
|
|
procedure Error_Msg_SP (Msg : String) is
|
|
begin
|
|
-- Note: in the case where there is no previous token, Prev_Token_Ptr
|
|
-- is set to Source_First, which is a reasonable position for the
|
|
-- error flag in this situation
|
|
|
|
Error_Msg (Msg, Prev_Token_Ptr);
|
|
end Error_Msg_SP;
|
|
|
|
--------------
|
|
-- Finalize --
|
|
--------------
|
|
|
|
procedure Finalize (Source_Type : String := "project") is
|
|
Cur : Error_Msg_Id;
|
|
Nxt : Error_Msg_Id;
|
|
E, F : Error_Msg_Id;
|
|
Err_Flag : Boolean;
|
|
|
|
begin
|
|
-- Eliminate any duplicated error messages from the list. This is
|
|
-- done after the fact to avoid problems with Change_Error_Text.
|
|
|
|
Cur := First_Error_Msg;
|
|
while Cur /= No_Error_Msg loop
|
|
Nxt := Errors.Table (Cur).Next;
|
|
|
|
F := Nxt;
|
|
while F /= No_Error_Msg
|
|
and then Errors.Table (F).Sptr = Errors.Table (Cur).Sptr
|
|
loop
|
|
Check_Duplicate_Message (Cur, F);
|
|
F := Errors.Table (F).Next;
|
|
end loop;
|
|
|
|
Cur := Nxt;
|
|
end loop;
|
|
|
|
-- Brief Error mode
|
|
|
|
if Brief_Output or (not Full_List and not Verbose_Mode) then
|
|
E := First_Error_Msg;
|
|
Set_Standard_Error;
|
|
|
|
while E /= No_Error_Msg loop
|
|
if not Errors.Table (E).Deleted then
|
|
if Full_Path_Name_For_Brief_Errors then
|
|
Write_Name (Full_Ref_Name (Errors.Table (E).Sfile));
|
|
else
|
|
Write_Name (Reference_Name (Errors.Table (E).Sfile));
|
|
end if;
|
|
|
|
Write_Char (':');
|
|
Write_Int (Int (Physical_To_Logical
|
|
(Errors.Table (E).Line,
|
|
Errors.Table (E).Sfile)));
|
|
Write_Char (':');
|
|
|
|
if Errors.Table (E).Col < 10 then
|
|
Write_Char ('0');
|
|
end if;
|
|
|
|
Write_Int (Int (Errors.Table (E).Col));
|
|
Write_Str (": ");
|
|
Output_Msg_Text (E);
|
|
Write_Eol;
|
|
end if;
|
|
|
|
E := Errors.Table (E).Next;
|
|
end loop;
|
|
|
|
Set_Standard_Output;
|
|
end if;
|
|
|
|
-- Full source listing case
|
|
|
|
if Full_List then
|
|
List_Pragmas_Index := 1;
|
|
List_Pragmas_Mode := True;
|
|
E := First_Error_Msg;
|
|
Write_Eol;
|
|
|
|
-- First list initial main source file with its error messages
|
|
|
|
for N in 1 .. Last_Source_Line (Main_Source_File) loop
|
|
Err_Flag :=
|
|
E /= No_Error_Msg
|
|
and then Errors.Table (E).Line = N
|
|
and then Errors.Table (E).Sfile = Main_Source_File;
|
|
|
|
Output_Source_Line (N, Main_Source_File, Err_Flag, Source_Type);
|
|
|
|
if Err_Flag then
|
|
Output_Error_Msgs (E);
|
|
|
|
Write_Eol;
|
|
end if;
|
|
end loop;
|
|
|
|
-- Then output errors, if any, for subsidiary units
|
|
|
|
while E /= No_Error_Msg
|
|
and then Errors.Table (E).Sfile /= Main_Source_File
|
|
loop
|
|
Write_Eol;
|
|
Output_Source_Line
|
|
(Errors.Table (E).Line,
|
|
Errors.Table (E).Sfile,
|
|
True,
|
|
Source_Type);
|
|
Output_Error_Msgs (E);
|
|
end loop;
|
|
end if;
|
|
|
|
-- Verbose mode (error lines only with error flags)
|
|
|
|
if Verbose_Mode then
|
|
E := First_Error_Msg;
|
|
|
|
-- Loop through error lines
|
|
|
|
while E /= No_Error_Msg loop
|
|
Write_Eol;
|
|
Output_Source_Line
|
|
(Errors.Table (E).Line,
|
|
Errors.Table (E).Sfile,
|
|
True,
|
|
Source_Type);
|
|
Output_Error_Msgs (E);
|
|
end loop;
|
|
end if;
|
|
|
|
-- Output error summary if verbose or full list mode
|
|
|
|
if Verbose_Mode or else Full_List then
|
|
|
|
-- Extra blank line if error messages or source listing were output
|
|
|
|
if Total_Errors_Detected + Warnings_Detected > 0
|
|
or else Full_List
|
|
then
|
|
Write_Eol;
|
|
end if;
|
|
|
|
-- Message giving number of lines read and number of errors detected.
|
|
-- This normally goes to Standard_Output. The exception is when brief
|
|
-- mode is not set, verbose mode (or full list mode) is set, and
|
|
-- there are errors. In this case we send the message to standard
|
|
-- error to make sure that *something* appears on standard error in
|
|
-- an error situation.
|
|
|
|
-- Formerly, only the "# errors" suffix was sent to stderr, whereas
|
|
-- "# lines:" appeared on stdout. This caused problems on VMS when
|
|
-- the stdout buffer was flushed, giving an extra line feed after
|
|
-- the prefix.
|
|
|
|
if Total_Errors_Detected + Warnings_Detected /= 0
|
|
and then not Brief_Output
|
|
and then (Verbose_Mode or Full_List)
|
|
then
|
|
Set_Standard_Error;
|
|
end if;
|
|
|
|
-- Message giving total number of lines
|
|
|
|
Write_Str (" ");
|
|
Write_Int (Num_Source_Lines (Main_Source_File));
|
|
|
|
if Num_Source_Lines (Main_Source_File) = 1 then
|
|
Write_Str (" line: ");
|
|
else
|
|
Write_Str (" lines: ");
|
|
end if;
|
|
|
|
if Total_Errors_Detected = 0 then
|
|
Write_Str ("No errors");
|
|
|
|
elsif Total_Errors_Detected = 1 then
|
|
Write_Str ("1 error");
|
|
|
|
else
|
|
Write_Int (Total_Errors_Detected);
|
|
Write_Str (" errors");
|
|
end if;
|
|
|
|
if Warnings_Detected /= 0 then
|
|
Write_Str (", ");
|
|
Write_Int (Warnings_Detected);
|
|
Write_Str (" warning");
|
|
|
|
if Warnings_Detected /= 1 then
|
|
Write_Char ('s');
|
|
end if;
|
|
|
|
if Warning_Mode = Treat_As_Error then
|
|
Write_Str (" (treated as error");
|
|
|
|
if Warnings_Detected /= 1 then
|
|
Write_Char ('s');
|
|
end if;
|
|
|
|
Write_Char (')');
|
|
end if;
|
|
end if;
|
|
|
|
Write_Eol;
|
|
Set_Standard_Output;
|
|
end if;
|
|
|
|
if Maximum_Errors /= 0
|
|
and then Total_Errors_Detected + Warnings_Detected = Maximum_Errors
|
|
then
|
|
Set_Standard_Error;
|
|
Write_Str ("fatal error: maximum errors reached");
|
|
Write_Eol;
|
|
Set_Standard_Output;
|
|
end if;
|
|
|
|
if Warning_Mode = Treat_As_Error then
|
|
Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected;
|
|
Warnings_Detected := 0;
|
|
end if;
|
|
end Finalize;
|
|
|
|
----------------
|
|
-- Initialize --
|
|
----------------
|
|
|
|
procedure Initialize is
|
|
begin
|
|
Errors.Init;
|
|
First_Error_Msg := No_Error_Msg;
|
|
Last_Error_Msg := No_Error_Msg;
|
|
Serious_Errors_Detected := 0;
|
|
Total_Errors_Detected := 0;
|
|
Warnings_Detected := 0;
|
|
Cur_Msg := No_Error_Msg;
|
|
|
|
-- Initialize warnings table, if all warnings are suppressed, supply
|
|
-- an initial dummy entry covering all possible source locations.
|
|
|
|
Warnings.Init;
|
|
end Initialize;
|
|
|
|
------------------------
|
|
-- Output_Source_Line --
|
|
------------------------
|
|
|
|
procedure Output_Source_Line
|
|
(L : Physical_Line_Number;
|
|
Sfile : Source_File_Index;
|
|
Errs : Boolean;
|
|
Source_Type : String)
|
|
is
|
|
S : Source_Ptr;
|
|
C : Character;
|
|
|
|
Line_Number_Output : Boolean := False;
|
|
-- Set True once line number is output
|
|
|
|
begin
|
|
if Sfile /= Current_Error_Source_File then
|
|
Write_Str ("==============Error messages for ");
|
|
Write_Str (Source_Type);
|
|
Write_Str (" file: ");
|
|
Write_Name (Full_File_Name (Sfile));
|
|
Write_Eol;
|
|
Current_Error_Source_File := Sfile;
|
|
end if;
|
|
|
|
if Errs then
|
|
Output_Line_Number (Physical_To_Logical (L, Sfile));
|
|
Line_Number_Output := True;
|
|
end if;
|
|
|
|
S := Line_Start (L, Sfile);
|
|
|
|
loop
|
|
C := Source_Text (Sfile) (S);
|
|
exit when C = ASCII.LF or else C = ASCII.CR or else C = EOF;
|
|
|
|
if Errs then
|
|
Write_Char (C);
|
|
end if;
|
|
|
|
S := S + 1;
|
|
end loop;
|
|
|
|
if Line_Number_Output then
|
|
Write_Eol;
|
|
end if;
|
|
end Output_Source_Line;
|
|
|
|
-----------------------
|
|
-- Set_Ignore_Errors --
|
|
-----------------------
|
|
|
|
procedure Set_Ignore_Errors (To : Boolean) is
|
|
begin
|
|
Errors_Must_Be_Ignored := To;
|
|
end Set_Ignore_Errors;
|
|
|
|
------------------------------
|
|
-- Set_Msg_Insertion_Column --
|
|
------------------------------
|
|
|
|
procedure Set_Msg_Insertion_Column is
|
|
begin
|
|
if Style.RM_Column_Check then
|
|
Set_Msg_Str (" in column ");
|
|
Set_Msg_Int (Int (Error_Msg_Col) + 1);
|
|
end if;
|
|
end Set_Msg_Insertion_Column;
|
|
|
|
------------------
|
|
-- Set_Msg_Text --
|
|
------------------
|
|
|
|
procedure Set_Msg_Text (Text : String; Flag : Source_Ptr) is
|
|
C : Character; -- Current character
|
|
P : Natural; -- Current index;
|
|
|
|
begin
|
|
Manual_Quote_Mode := False;
|
|
Msglen := 0;
|
|
Flag_Source := Get_Source_File_Index (Flag);
|
|
P := Text'First;
|
|
|
|
while P <= Text'Last loop
|
|
C := Text (P);
|
|
P := P + 1;
|
|
|
|
-- Check for insertion character
|
|
|
|
if C = '%' then
|
|
Set_Msg_Insertion_Name;
|
|
|
|
elsif C = '$' then
|
|
|
|
-- '$' is ignored
|
|
|
|
null;
|
|
|
|
elsif C = '{' then
|
|
Set_Msg_Insertion_File_Name;
|
|
|
|
elsif C = '}' then
|
|
|
|
-- '}' is ignored
|
|
|
|
null;
|
|
|
|
elsif C = '*' then
|
|
Set_Msg_Insertion_Reserved_Name;
|
|
|
|
elsif C = '&' then
|
|
|
|
-- '&' is ignored
|
|
|
|
null;
|
|
|
|
elsif C = '#' then
|
|
Set_Msg_Insertion_Line_Number (Error_Msg_Sloc, Flag);
|
|
|
|
elsif C = '\' then
|
|
Continuation := True;
|
|
|
|
elsif C = '@' then
|
|
Set_Msg_Insertion_Column;
|
|
|
|
elsif C = '^' then
|
|
Set_Msg_Insertion_Uint;
|
|
|
|
elsif C = '`' then
|
|
Manual_Quote_Mode := not Manual_Quote_Mode;
|
|
Set_Msg_Char ('"');
|
|
|
|
elsif C = '!' then
|
|
Is_Unconditional_Msg := True;
|
|
|
|
elsif C = '?' then
|
|
null;
|
|
|
|
elsif C = '<' then
|
|
null;
|
|
|
|
elsif C = '|' then
|
|
null;
|
|
|
|
elsif C = ''' then
|
|
Set_Msg_Char (Text (P));
|
|
P := P + 1;
|
|
|
|
-- Upper case letter (start of reserved word if 2 or more)
|
|
|
|
elsif C in 'A' .. 'Z'
|
|
and then P <= Text'Last
|
|
and then Text (P) in 'A' .. 'Z'
|
|
then
|
|
P := P - 1;
|
|
Set_Msg_Insertion_Reserved_Word (Text, P);
|
|
|
|
-- Normal character with no special treatment
|
|
|
|
else
|
|
Set_Msg_Char (C);
|
|
end if;
|
|
|
|
end loop;
|
|
end Set_Msg_Text;
|
|
|
|
end Errutil;
|