[FIX][VM] SLANG zapping warning messages fum does not return int, or variable foo not used
John M McIntosh
johnmci at smalltalkconsulting.com
Mon Nov 25 07:29:23 UTC 2002
For many years now I and others have been annoyed that SLANG generates
int foo(arg) where foo returns
void!. This results in compiler warnings, somehow not having compiler
warning messages is good and saves me
from explain to novices that they need to ignore them.
Also warnings about "int type21212" variable is not used, because
either:
a) the variable has disappeared because inline has disposed of it.
b) the if block containing the variable has disappeared because the
boolean constant is shown to
resolve to a falsehood and the block is never extruded because it's
never executed, however the variable is
kept thus clouding the issue.
Both issues are really handled by smart compilers, but perhaps stupid
ones generate poor code when you confuse them with bogus return types
and non-used variables.
So being that I've all the source code I decided yesterday to fix it.
Right now I've got a VM that builds without ANY warnings from interp.c
SLANG now will declare a function void if the function does not return
a type! Really kinda of obvious.
In a few places I had to add self cCode: 'return' inSmalltalk: [^self].
to allow a guard clause to return
early without a value, originally it would have returned a bogus value
for this special case, which is bogus since other returns just
return self.
A couple of places in sq.h insist that a VM routine returns a value,
but the routine does NOT. {that's not included in this changeset}
A dozen or so places like so were fixed:
primitiveFloatDivide
^self primitiveFloatDivide: (self stackValue: 1) byArg: self stackTop
but primitiveFloatDivide:byArg: doesn't return anything (but self).
For all instances of nodesDo: aBlock I created a nodesVarCheckDo:
aBlock so that I could make
a decision on how to invoke nodesVarCheckDo: on the substructure so
that statements like
"false ifTrue: []" are ignored for method variable name resolution,
and a special case for selector
#cCode:inSmalltalk: to handle it correctly.
The attached changeset then allows one to build a VM with fewer
warnings.
Lots of missing function prototypes in b3dDraw like ...
void b3dDrawRGBFlat(int leftX, int rightX, int yValue, B3DPrimitiveFace
*face)
I have noted that some methods return values that are never used, the
caller always ignores the result, sounds like a job for Lint.
IE like writeImageFileIO which returns nil in some places, but it's
really just an early return and should be self cCode: 'return'
inSmalltalk: [^self].
because no-one cares about the writeImageFileIO return value.
--
========================================================================
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
========================================================================
===
-------------- next part --------------
A non-text attachment was scrubbed...
Name: voidIsVoidNotInt.4.cs.gz
Type: application/x-gzip
Size: 6851 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20021124/439f9602/voidIsVoidNotInt.4.cs.bin
More information about the Squeak-dev
mailing list
|