mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-03-06 06:29:57 +00:00
Allow #pragma lint messages to optionally be treated as warnings.
In the #pragma lint line, the integer indicating the checks to perform can now optionally be followed by a semicolon and another integer. If these are present and the second integer is 0, then the lint checks will be performed, but will be treated as warnings rather than errors, so that they do not cause compilation to fail.
This commit is contained in:
parent
40e2b770ae
commit
fe6c410271
@ -501,6 +501,7 @@ var
|
||||
unix_1: boolean; {is int 32 bits? (or 16 bits)}
|
||||
useGlobalPool: boolean; {use global (or local) string pool?}
|
||||
wait: boolean; {wait for keypress after errors?}
|
||||
lintIsError: boolean; {treat lint messages as errors?}
|
||||
|
||||
{syntactic classes of tokens}
|
||||
{---------------------------}
|
||||
|
12
Header.pas
12
Header.pas
@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI;
|
||||
{$segment 'SCANNER'}
|
||||
|
||||
const
|
||||
symFileVersion = 5; {version number of .sym file format}
|
||||
symFileVersion = 6; {version number of .sym file format}
|
||||
|
||||
var
|
||||
inhibitHeader: boolean; {should .sym includes be blocked?}
|
||||
@ -823,7 +823,10 @@ procedure EndInclude {chPtr: ptr};
|
||||
| (ord(checkStack) << 4)
|
||||
| (ord(debugStrFlag) << 15));
|
||||
|
||||
p_lint: WriteWord(lint);
|
||||
p_lint: begin
|
||||
WriteWord(lint);
|
||||
WriteByte(ord(lintIsError));
|
||||
end;
|
||||
|
||||
p_memorymodel: WriteByte(ord(smallMemoryModel));
|
||||
|
||||
@ -1456,7 +1459,10 @@ var
|
||||
debugStrFlag := odd(val >> 15);
|
||||
end;
|
||||
|
||||
p_lint: lint := ReadWord;
|
||||
p_lint: begin
|
||||
lint := ReadWord;
|
||||
lintIsError := boolean(ReadByte);
|
||||
end;
|
||||
|
||||
p_memorymodel: smallMemoryModel := boolean(ReadByte);
|
||||
|
||||
|
21
Scanner.pas
21
Scanner.pas
@ -675,7 +675,7 @@ if list or (numErr <> 0) then begin
|
||||
otherwise: Error(57);
|
||||
end; {case}
|
||||
writeln(msg^);
|
||||
if terminalErrors then begin
|
||||
if terminalErrors and (numErrors <> 0) then begin
|
||||
if enterEditor then begin
|
||||
if line = lineNumber then
|
||||
ExitToEditor(msg, ord4(firstPtr)+col-ord4(bofPtr)-1)
|
||||
@ -2765,6 +2765,11 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin
|
||||
FlagPragmas(p_lint);
|
||||
NumericDirective;
|
||||
lint := long(expressionValue).lsw;
|
||||
lintIsError := true;
|
||||
if token.kind = semicolonch then begin
|
||||
NumericDirective;
|
||||
lintIsError := expressionValue <> 0;
|
||||
end; {if}
|
||||
if token.kind <> eolsy then
|
||||
Error(11);
|
||||
goto 2;
|
||||
@ -2974,19 +2979,26 @@ procedure Error {err: integer};
|
||||
{ err - error number }
|
||||
|
||||
begin {Error}
|
||||
if lintIsError or not (err in [51,104,105,110,124,125,128,129,130,147])
|
||||
then begin
|
||||
if (numErr <> maxErr) or (numErrors = 0) then
|
||||
numErrors := numErrors+1;
|
||||
liDCBGS.merrf := 16;
|
||||
end {if}
|
||||
else
|
||||
TermHeader;
|
||||
if numErr = maxErr then {set the error number}
|
||||
errors[maxErr].num := 4
|
||||
else begin
|
||||
numErr := numErr+1;
|
||||
numErrors := numErrors+1;
|
||||
liDCBGS.merrf := 16;
|
||||
errors[numErr].num := err;
|
||||
end; {else}
|
||||
with errors[numErr] do begin {record the position of the error}
|
||||
line := tokenLine;
|
||||
col := tokenColumn;
|
||||
end; {with}
|
||||
codeGeneration := false; {inhibit code generation}
|
||||
if numErrors <> 0 then
|
||||
codeGeneration := false; {inhibit code generation}
|
||||
end; {Error}
|
||||
|
||||
|
||||
@ -3611,6 +3623,7 @@ lastWasReturn := false; {last char was not return}
|
||||
doingstring := false; {not doing a string}
|
||||
doingPPExpression := false; {not doing a preprocessor expression}
|
||||
unix_1 := false; {int is 16 bits}
|
||||
lintIsError := true; {lint messages are considered errors}
|
||||
|
||||
new(mp); {__LINE__}
|
||||
mp^.name := @'__LINE__';
|
||||
|
10
cc.notes
10
cc.notes
@ -170,7 +170,9 @@ Bit 4 controls whether C99-style scope rules are followed and whether mixed stat
|
||||
|
||||
p. 259
|
||||
|
||||
The #pragma lint directive supports two new bits.
|
||||
The #pragma lint directive can now optionally treat messages from lint checks as warnings rather than errors. To make it work this way, add ";0" after the integer value indicating the lint checks to perform.
|
||||
|
||||
In addition, two new types of lint checks are now available:
|
||||
|
||||
If bit 4 (a value of 16) is set, the compiler will check if the format strings passed to the fprintf() and fscanf() families of functions are valid, and if the number and types of arguments passed to them match what the format strings call for. See "Format Checking," below.
|
||||
|
||||
@ -370,6 +372,12 @@ These behave the same as the existing tokens [, ], {, }, #, and ## (respectively
|
||||
|
||||
16. (C99) Any or all of the arguments to a function-like macro can be empty. (This happened to work previously in some cases but not others.)
|
||||
|
||||
17. The #pragma lint directive can now optionally be configured to perform its checks but treat any messages produced as warnings rather than errors, so that they do not cause compilation to fail. To make it work this way, add ";0" after the integer value indicating the checks to perform. For example, you can use
|
||||
|
||||
#pragma lint -1;0
|
||||
|
||||
to perform all lint checks but treat them as warnings rather than errors.
|
||||
|
||||
|
||||
Multi-Character Character Constants
|
||||
-----------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user