From 7322428e1d4734f03c5f1cb3f61cfadbde9e7fc3 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 4 Feb 2022 22:10:50 -0600 Subject: [PATCH] Add an option to print file names in error messages. This can help identify if an error is in the main source file or an include file. --- CC.pas | 1 + CCommon.pas | 2 ++ Scanner.pas | 5 +++++ cc.notes | 13 +++++++++++++ 4 files changed, 21 insertions(+) diff --git a/CC.pas b/CC.pas index c6c7275..8554a44 100644 --- a/CC.pas +++ b/CC.pas @@ -56,6 +56,7 @@ sourceFileGS := includeFileGS; doingPartial := partialFileGS.theString.size <> 0; with liDCBGS do begin enterEditor := pFlags & flag_e <> 0; {enter editor on terminal errors?} + filenamesInErrors := pFlags & flag_f <> 0; {filenames in error messages?} ignoreSymbols := mFlags & flag_i <> 0; {ignore symbol file?} list := pFlags & flag_l <> 0; {list the source file?} memoryCompile := pflags & flag_m <> 0; {memory based compile?} diff --git a/CCommon.pas b/CCommon.pas index 9ffa432..9ae2d86 100644 --- a/CCommon.pas +++ b/CCommon.pas @@ -98,6 +98,7 @@ const {----------------------------} flag_d = $10000000; {generate debug code?} flag_e = $08000000; {abort to editor on terminal error?} + flag_f = $04000000; {print filenames in error messages?} flag_i = $00800000; {ignore symbol files?} flag_l = $00100000; {list source lines?} flag_m = $00080000; {memory based compile?} @@ -521,6 +522,7 @@ var doingFunction: boolean; {are we processing a function?} doingPartial: boolean; {are we doing a partial compile?} enterEditor: boolean; {enter editor on terminal errors?} + filenamesInErrors: boolean; {print filenames in error messages?} foundFunction: boolean; {has a function been found?} lint: integer; {lint flags} list: boolean; {generate source listing?} diff --git a/Scanner.pas b/Scanner.pas index 3cf4c5f..07652a8 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -542,6 +542,9 @@ var begin {WriteLine} if list or (numErr <> 0) then begin if not wroteLine and not doingCommandLine then begin + if numErr <> 0 then + if filenamesInErrors then + writeln('In ',sourceFileGS.theString.theString,':'); write(lineNumber:4, ' '); {write the line #} cp := firstPtr; {write the characters in the line} while (cp <> eofPtr) and (charKinds[ord(cp^)] <> ch_eol) do begin @@ -1135,6 +1138,8 @@ if len > 255 then pstr^[0] := chr(len); for i := 1 to len do pstr^[i] := lstr^.str[i]; +if len < 255 then + pstr^[len+1] := chr(0); end; {LongToPString} diff --git a/cc.notes b/cc.notes index fc2de67..c9ff610 100644 --- a/cc.notes +++ b/cc.notes @@ -44,6 +44,9 @@ Updated by Stephen Heumann and Kelvin Sherlock, 2017-2022 14. New bit added to control floating-point optimizations that may violate the IEEE standard. See "Floating-Point Optimizations." + 15. New option to print file names in error messages. See + "File Names in Error Messages." + 2.1.1 B3 1. Bugs squashed. See bug notes, below. 2.1.0 1. Bugs squashed. See bug notes, below. @@ -111,6 +114,10 @@ p. 107 The table shows the language number for C as 7. It should be 8. +p. 128 + +The ASML, ASMLG, ASSEMBLE, CMPL, CMPLG, COMPILE, and RUN commands now accept a new flag, +F. The +F flag causes the compiler to include the file name in any error messages that it prints. It is currently only effective for ORCA/C. + p. 233 Identifiers may now contain universal character names, a type of escape sequence that can denote a Unicode character. See "New Language Features," below. @@ -621,6 +628,12 @@ ORCA/C can now detect several elements of C syntax that were allowed in C89 but If #pragma lint bit 7 (a value of 128) is set, ORCA/C detects some situations where a function with a non-void return type may return an unpredictable value, either by executing a return statement with no value or by executing to the end of the function with no return statement. (The former case is also detected by #pragma lint bit 6.) It also detects some situations where a _Noreturn function could return. Note that these checks only detect some cases of these problems, not all of them. Also, they may report a potential problem in some situations where the code at the end of a function is not actually reachable. +File Names in Error Messages +---------------------------- + +When ORCA/C prints out error messages, it can now optionally include the name of the file containing the error. This can help you to understand whether an error is in the main source file or an include file. To enable this option, use the new +F flag to the ASML, ASMLG, ASSEMBLE, CMPL, CMPLG, COMPILE, or RUN commands. + + Locales -------