Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site elsie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.lang.c Subject: 4.1bsd lint additions to catch "if (condition) ;" Message-ID: <5205@elsie.UUCP> Date: Sun, 18-Aug-85 21:50:55 EDT Article-I.D.: elsie.5205 Posted: Sun Aug 18 21:50:55 1985 Date-Received: Tue, 20-Aug-85 21:40:31 EDT References: <389@phri.UUCP> Distribution: net Organization: NIH-LEC, Bethesda, MD Lines: 84 In article <389@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes: > > Here's one that just got me: > > if (sv > score); <----- note extraneous semi-colon > score = sv; Here are additions to 4.1bsd's "lint" to catch constructs like that above. Warnings are only produced if lint's "-h" flag is used. Two files are involved. In the description below, all code to be added appears between "#ifndef OLDVERSION" and "#endif" directives. As usual, the trade secret status of the code precludes a clearer posting. First, additions to "lint.c". Add this declaration just before the function "ecode": #ifndef OLDVERSION char * gripenull; #endif . . .and, as the last statement in "ecode", add this: #ifndef OLDVERSION gripenull = 0; #endif Second, additions to "cgram.y". Just after the declaration of "fake", add a declaration of "gripenull": #ifndef OLDVERSION extern char * gripenull; #endif In the code handling the "ifprefix statement" variant of a "statement" add this code: | ifprefix statement ={ deflab($1); #ifndef OLDVERSION gripenull = 0; #endif In the code handling the "ifelprefix statement" variant of a "statement" add this code: | ifelprefix statement ={ if( $1 != NOLAB ){ deflab( $1 ); reached = 1; } #ifndef OLDVERSION gripenull = 0; #endif In the code handling the "SM" variant of a "statement" add this code: | SM /* #ifndef OLDVERSION */ ={ if (hflag && gripenull != 0) werror(gripenull); } /* #endif OLDVERSION */ In the code for "ifprefix"es, add this code: ={ ecomp( buildtree( CBRANCH, $3, bcon( $$=getlab()) ) ) ; #ifndef OLDVERSION gripenull = "bodyless if"; #endif And, finally, in the code for "ifelprefix"es, add this code: ={ if( reached ) branch( $$ = getlab() ); else $$ = NOLAB; #ifndef OLDVERSION gripenull = "bodyless else"; #endif -- Lint is an Oscar Madison trademark. -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX and Elsie are Digital Equipment and Borden trademarks