Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP Path: utzoo!watmath!rbutterworth From: rbutterworth@watmath.UUCP (Ray Butterworth) Newsgroups: net.lang.c Subject: Re: expr?(void):(void) WHY I THINK IT'S *OK* ( or should be ) Message-ID: <2278@watmath.UUCP> Date: Thu, 7-Aug-86 10:34:31 EDT Article-I.D.: watmath.2278 Posted: Thu Aug 7 10:34:31 1986 Date-Received: Sat, 9-Aug-86 05:35:34 EDT References: <501@bunny.UUCP> <500@copper.UUCP> <273@watmath.UUCP> <3220@utcsri.UUCP> Distribution: net Organization: U of Waterloo, Ontario Lines: 73 > Lint obviously does *some* analysis of this, since it can say > "constant in conditional context". BTW, I have a program that gives > that error, but the expression is in an ARRAY DIMENSION for crissake. > char foo[ THING1 > THING2 ? THING1 : THING2 ]; > Obviously it's going to be a constant. Any lint authors listening? > Turn that off when a constant expression is called for. While I'm > wishing for things, I wanna see 'assignment in conditional context'. > We all know why by now... ------/usr/src/lib/mip/cgram.y------(look for "con_e:") /* EXPRESSIONS */ con_e: { #ifdef LINT {extern int constexp;} constexp=1; #endif $$=instruct; stwart=instruct=0; } e %prec CM ={ $$ = icons( $2 ); instruct=$1; #ifdef LINT constexp=0; #endif } ; .e: e ------/usr/src/lib/mip/trees.c------(look for warning message) case BRANCH: ccwarn: #ifdef LINT {extern int constexp;} if (hflag&&!constexp) werror("constant in conditional context"); #endif case PLUS: ------/usr/src/usr.bin/lint/lpass1.c------(add to definitions of externals) int constexp=0; ------/usr/src/usr.bin/lint/lpass1.c------(in function contx()) contx( p, down, pl, pr ) register NODE *p; register *pl, *pr; { *pl = *pr = VAL; if (p->in.type==UNDEF) down=VAL; /* (void) cast */ switch( p->in.op ){ case NOT: *pl=down; case ANDAND: case OROR: if (hflag&&(p->in.right->in.op==ASSIGN)) werror("Possible unintended assignment"); case QUEST: *pr = down; case CBRANCH: if (hflag&&(p->in.left->in.op==ASSIGN)) werror("possible unintended assignment"); break; case SCONV: case PCONV: