mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-16 14:29:30 +00:00
Add lint check for return with no value in a non-void function.
This is disallowed in C99 and later.
This commit is contained in:
parent
a9f5fb13d8
commit
4fd642abb4
|
@ -763,7 +763,12 @@ var
|
||||||
end;
|
end;
|
||||||
otherwise: ;
|
otherwise: ;
|
||||||
end; {case}
|
end; {case}
|
||||||
end; {if}
|
end {if}
|
||||||
|
else begin
|
||||||
|
if (fType^.kind <> scalarType) or (fType^.baseType <> cgVoid) then
|
||||||
|
if (lint & lintC99Syntax) <> 0 then
|
||||||
|
Error(152);
|
||||||
|
end; {else}
|
||||||
Gen1(pc_ujp, returnLabel); {branch to the exit point}
|
Gen1(pc_ujp, returnLabel); {branch to the exit point}
|
||||||
Match(semicolonch, 22); {insist on a closing ';'}
|
Match(semicolonch, 22); {insist on a closing ';'}
|
||||||
end; {ReturnStatement}
|
end; {ReturnStatement}
|
||||||
|
|
|
@ -182,7 +182,7 @@ const
|
||||||
{----}
|
{----}
|
||||||
defaultName = '13:ORCACDefs:Defaults.h'; {default include file name}
|
defaultName = '13:ORCACDefs:Defaults.h'; {default include file name}
|
||||||
maxErr = 10; {max errors on one line}
|
maxErr = 10; {max errors on one line}
|
||||||
maxLint = 151; {maximum lint error code}
|
maxLint = 152; {maximum lint error code}
|
||||||
|
|
||||||
type
|
type
|
||||||
errorType = record {record of a single error}
|
errorType = record {record of a single error}
|
||||||
|
@ -676,6 +676,7 @@ if list or (numErr <> 0) then begin
|
||||||
149: msg := @'invalid universal character name for use in an identifier';
|
149: msg := @'invalid universal character name for use in an identifier';
|
||||||
150: msg := @'designated initializers are not supported by ORCA/C';
|
150: msg := @'designated initializers are not supported by ORCA/C';
|
||||||
151: msg := @'lint: type specifier missing';
|
151: msg := @'lint: type specifier missing';
|
||||||
|
152: msg := @'lint: return with no value in non-void function';
|
||||||
otherwise: Error(57);
|
otherwise: Error(57);
|
||||||
end; {case}
|
end; {case}
|
||||||
writeln(msg^);
|
writeln(msg^);
|
||||||
|
@ -3636,7 +3637,7 @@ lintIsError := true; {lint messages are considered errors}
|
||||||
|
|
||||||
{error codes for lint messages}
|
{error codes for lint messages}
|
||||||
{if changed, also change maxLint}
|
{if changed, also change maxLint}
|
||||||
lintErrors := [51,104,105,110,124,125,128,129,130,147,151];
|
lintErrors := [51,104,105,110,124,125,128,129,130,147,151,152];
|
||||||
|
|
||||||
new(mp); {__LINE__}
|
new(mp); {__LINE__}
|
||||||
mp^.name := @'__LINE__';
|
mp^.name := @'__LINE__';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user