Hi Maarten, hi Paul,
Maarten Brock schrieb:
> Hi,
>
> I've never used any but I wonder what a lint would do
> with this.
>
> Maarten
>
>
>> frieder wrote:
>> > Hi Arkadi
>> >
>> > Arkadi Shishlov schrieb:
>> > > Is it possible to get a warning from the compiler for suspicious lines
>> of
>> > code like
>> > > some_var == 123;
>> > > that makes little sense.
>> > > ?
>> >
>> > Indeed!)
>> >
>> > This one probably makes even less sense but also
>> > passes without error (both GCC and SDCC:)
>>
>> GCC gives plenty of warnings with -Wall:
>> $ gcc -Wall f.c
>> f.c: In function 'main':
>> f.c:5: warning: the address of 'foo' will always evaluate as 'true'
>> f.c:7: warning: the address of 'foo' will always evaluate as 'true'
>> f.c:8: warning: left-hand operand of comma expression has no effect
>> f.c:8: warning: left-hand operand of comma expression has no effect
>> f.c:8: warning: statement with no effect
>> f.c:8: warning: statement with no effect
>> f.c:10: warning: statement with no effect
>> f.c:12: warning: statement with no effect
>> f.c:14: warning: statement with no effect
>> f.c:17: warning: statement with no effect
>> f.c:20: warning: statement with no effect
>> f.c:23: warning: statement with no effect
>> f.c:23: warning: statement with no effect
>> f.c:25: warning: statement with no effect
splint (www.splint.org) gives:
> splint f.c
Splint 3.1.2 --- 14 Aug 2008
f.c: (in function main)
f.c:3:13: Test expression for conditional not boolean, type [function ()
returns void]: foo
Test expression type is not boolean. (Use -predboolothers to inhibit warning)
f.c:6:12: Operands of && are non-booleans ([function () returns void], int):
foo && i--
The operand of a boolean operator is not a boolean. Use +ptrnegate to allow !
to be used on pointers. (Use -boolops to inhibit warning)
f.c:7:9: Statement has no effect: 1
Statement has no visible effect --- no values are modified. (Use -noeffect to
inhibit warning)
f.c:7:16: Statement has no effect: 4
f.c:9:5: Statement has no effect: 5
f.c:11:5: Statement has no effect: 5 == 6
f.c:13:5: Statement has no effect: 7 / 8 == 78
f.c:15:5: Test expression for conditional not boolean, type int: 7 / 8
Test expression type is not boolean or int. (Use -predboolint to inhibit
warning)
f.c:15:5: Statement has no effect: 7 / 8
f.c:18:5: Statement has no effect: "GCC 4.3.1 and S...
f.c:19:6: Statement has no effect: "to"
"be mor...
f.c:22:17: Statement has no effect: !"YES"
f.c:24:15: Operand of ! is non-boolean (int): !i
f.c:24:12: Test expression for conditional not boolean, type int: ~!!i
f.c:24:17: Conditional clauses are not of same type:
i == 8 (boolean), 8 % +8 (int)
To make bool and int types equivalent, use +boolint.
f.c:24:27: Statement has no effect: -7
f.c:24:27: Unreachable code: -7
This code will never be reached on any possible execution. (Use -unreachable
to inhibit warning)
f.c:25:2: Path with no return in function declared to return int
There is a path through a function declared to return a value on which there
is no return statement. This means the execution may fall through without
returning a meaningful result to the caller. (Use -noret to inhibit warning)
f.c:1:6: Function exported but not used outside f: foo
A declaration is exported, but not used outside this module. Declaration can
use static qualifier. (Use -exportlocal to inhibit warning)
f.c:1:13: Definition of foo
Finished checking --- 19 code warnings
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user