From b493dcb1dae553ab2fb8274df46c7683c9c352af Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 13 Feb 2022 19:33:38 -0600 Subject: [PATCH] Add lint check to require whitespace after names of object-like macros. This is a requirement added in C99, so it is added as part of the C99 syntax checks. This affects definitions like: #define foo; --- Scanner.pas | 8 ++++++-- cc.notes | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Scanner.pas b/Scanner.pas index c3adff2..0d0d985 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -184,7 +184,7 @@ const {----} defaultName = '13:ORCACDefs:Defaults.h'; {default include file name} maxErr = 10; {max errors on one line} - maxLint = 155; {maximum lint error code} + maxLint = 170; {maximum lint error code} type errorType = record {record of a single error} @@ -745,6 +745,7 @@ if list or (numErr <> 0) then begin 167: msg := @'''L''-prefixed character or string constants are not supported by ORCA/C'; 168: msg := @'malformed hexadecimal floating constant'; 169: msg := @'struct or array may not contain a struct with a flexible array member'; + 170: msg := @'lint: no whitespace after macro name'; otherwise: Error(57); end; {case} writeln(msg^); @@ -2502,6 +2503,9 @@ var Error(12); end {if} else begin + if (lint & lintC99Syntax) <> 0 then + if not (charKinds[ord(ch)] in [ch_white,ch_eol,ch_eof]) then + Error(170); parameters := -1; {no parameter list exists} NextToken; {done with the name token...} end; {else} @@ -4125,7 +4129,7 @@ pragmaKeepFile := nil; {no #pragma keep file so far} {error codes for lint messages} {if changed, also change maxLint} -lintErrors := [51,104,105,110,124,125,128,129,130,147,151,152,153,154,155]; +lintErrors := [51,104,105,110,124,125,128,129,130,147,151,152,153,154,155,170]; spaceStr := ' '; {strings used in stringization} quoteStr := '"'; diff --git a/cc.notes b/cc.notes index d16ad0d..510a4e6 100644 --- a/cc.notes +++ b/cc.notes @@ -627,6 +627,7 @@ ORCA/C can now detect several elements of C syntax that were allowed in C89 but (also detected by #pragma lint bit 7, described below) - Declarations or type names with no type specifiers (using 'implicit int') (This includes but is broader than what is checked by #pragma lint bit 1.) +- Object-like macro definitions with no whitespace after the macro name * Checking for functions not returning a value or returning inappropriately: