projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
decide whether you want to use float or double constants, not mixed type
[unix-history]
/
usr
/
src
/
old
/
pcc
/
lint
/
lpass1
/
lint.c
diff --git
a/usr/src/old/pcc/lint/lpass1/lint.c
b/usr/src/old/pcc/lint/lpass1/lint.c
index
9986a0d
..
7a6bef0
100644
(file)
--- a/
usr/src/old/pcc/lint/lpass1/lint.c
+++ b/
usr/src/old/pcc/lint/lpass1/lint.c
@@
-1,11
+1,10
@@
-
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)lint.c 1.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)lint.c 1.
7
(Berkeley) %G%";
#endif lint
#endif lint
-# include "
mfile1
"
+# include "
pass1.h
"
-# include "lmanifest"
+# include "lmanifest
.h
"
# include <ctype.h>
# include <ctype.h>
@@
-35,6
+34,9
@@
int argflag = 0; /* used to turn off complaints about arguments */
int libflag = 0; /* used to generate library descriptions */
int vaflag = -1; /* used to signal functions with a variable number of args */
int aflag = 0; /* used to check precision of assignments */
int libflag = 0; /* used to generate library descriptions */
int vaflag = -1; /* used to signal functions with a variable number of args */
int aflag = 0; /* used to check precision of assignments */
+int zflag = 0; /* no 'structure never defined' error */
+int Cflag = 0; /* filter out certain output, for generating libraries */
+char *libname = 0; /* name of the library we're generating */
/* flags for the "outdef" function */
# define USUAL (-101)
/* flags for the "outdef" function */
# define USUAL (-101)
@@
-112,7
+114,8
@@
ejobcode( flag ){
if( p->stype != TNULL ) {
if( p->stype == STRTY || p->stype == UNIONTY ){
if( p->stype != TNULL ) {
if( p->stype == STRTY || p->stype == UNIONTY ){
- if( dimtab[p->sizoff+1] < 0 ){ /* never defined */
+ if( !zflag && dimtab[p->sizoff+1] < 0 ){
+ /* never defined */
#ifndef FLEXNAMES
if( hflag ) werror( "struct/union %.8s never defined", p->sname );
#else
#ifndef FLEXNAMES
if( hflag ) werror( "struct/union %.8s never defined", p->sname );
#else
@@
-136,6
+139,8
@@
ejobcode( flag ){
lineno = k;
break;
}
lineno = k;
break;
}
+ /* no statics in libraries */
+ if( Cflag ) break;
case EXTERN:
case USTATIC:
case EXTERN:
case USTATIC:
@@
-160,7
+165,7
@@
ejobcode( flag ){
astype( t, i ) ATYPE *t; {
TWORD tt;
astype( t, i ) ATYPE *t; {
TWORD tt;
- int j, k=0;
+ int j, k=0
, l=0
;
if( (tt=BTYPE(t->aty))==STRTY || tt==UNIONTY ){
if( i<0 || i>= DIMTABSZ-3 ){
if( (tt=BTYPE(t->aty))==STRTY || tt==UNIONTY ){
if( i<0 || i>= DIMTABSZ-3 ){
@@
-169,7
+174,8
@@
astype( t, i ) ATYPE *t; {
else {
j = dimtab[i+3];
if( j<0 || j>SYMTSZ ){
else {
j = dimtab[i+3];
if( j<0 || j>SYMTSZ ){
- k = ((-j)<<5)^dimtab[i]|1;
+ k = dimtab[i];
+ l = X_NONAME | stab[j].suse;
}
else {
if( stab[j].suse <= 0 ) {
}
else {
if( stab[j].suse <= 0 ) {
@@
-180,11
+186,19
@@
astype( t, i ) ATYPE *t; {
#endif
stab[j].sname );
}
#endif
stab[j].sname );
}
- else k = (stab[j].suse<<5) ^ dimtab[i];
+ else {
+ k = dimtab[i];
+#ifdef FLEXNAMES
+ l = hashstr(stab[j].sname);
+#else
+ l = hashstr(stab[j].sname, LCHNM);
+#endif
+ }
}
}
t->extra = k;
}
}
t->extra = k;
+ t->extra1 = l;
return( 1 );
}
else return( 0 );
return( 1 );
}
else return( 0 );
@@
-199,15
+213,20
@@
bfcode( a, n ) int a[]; {
static ATYPE t;
retlab = 1;
static ATYPE t;
retlab = 1;
+
cfp = &stab[curftn];
cfp = &stab[curftn];
+ /* if creating library, don't do static functions */
+ if( Cflag && cfp->sclass == STATIC ) return;
+
/* if variable number of arguments, only print the ones which will be checked */
if( vaflag > 0 ){
if( n < vaflag ) werror( "declare the VARARGS arguments you want checked!" );
else n = vaflag;
}
fsave( ftitle );
/* if variable number of arguments, only print the ones which will be checked */
if( vaflag > 0 ){
if( n < vaflag ) werror( "declare the VARARGS arguments you want checked!" );
else n = vaflag;
}
fsave( ftitle );
- outdef( cfp, libflag?LIB:LDI, vaflag>=0?-n:n );
+ if( cfp->sclass == STATIC ) outdef( cfp, LST, vaflag>=0?-n:n );
+ else outdef( cfp, libflag?LIB:LDI, vaflag>=0?-n:n );
vaflag = -1;
/* output the arguments */
vaflag = -1;
/* output the arguments */
@@
-215,6
+234,7
@@
bfcode( a, n ) int a[]; {
for( i=0; i<n; ++i ) {
t.aty = stab[a[i]].stype;
t.extra = 0;
for( i=0; i<n; ++i ) {
t.aty = stab[a[i]].stype;
t.extra = 0;
+ t.extra1 = 0;
if( !astype( &t, stab[a[i]].sizoff ) ) {
switch( t.aty ){
if( !astype( &t, stab[a[i]].sizoff ) ) {
switch( t.aty ){
@@
-261,8
+281,9
@@
lpta( p ) NODE *p; {
t.aty = p->in.type;
t.extra = (p->in.op==ICON);
t.aty = p->in.type;
t.extra = (p->in.op==ICON);
+ t.extra1 = 0;
- if( !astype( &t, p->
i
n.csiz ) ) {
+ if( !astype( &t, p->
f
n.csiz ) ) {
switch( t.aty ){
case CHAR:
switch( t.aty ){
case CHAR:
@@
-383,6
+404,13
@@
lprt( p, down, uses ) register NODE *p; {
if( p->in.left->in.op == ICON && (id=p->in.left->tn.rval) != NONAME ){ /* used to be &name */
struct symtab *sp = &stab[id];
int lty;
if( p->in.left->in.op == ICON && (id=p->in.left->tn.rval) != NONAME ){ /* used to be &name */
struct symtab *sp = &stab[id];
int lty;
+
+ fsave( ftitle );
+ /*
+ * if we're generating a library -C then
+ * we don't want to output references to functions
+ */
+ if( Cflag ) break;
/* if a function used in an effects context is
* cast to type void then consider its value
* to have been disposed of properly
/* if a function used in an effects context is
* cast to type void then consider its value
* to have been disposed of properly
@@
-397,8
+425,7
@@
lprt( p, down, uses ) register NODE *p; {
} else {
lty = LUV;
}
} else {
lty = LUV;
}
- fsave( ftitle );
- outdef(sp, lty, acount);
+ outdef( sp, lty, acount );
if( acount ) {
lpta( p->in.right );
}
if( acount ) {
lpta( p->in.right );
}
@@
-419,7
+446,7
@@
lprt( p, down, uses ) register NODE *p; {
q = &stab[id];
if( (uses&VALUSED) && !(q->sflags&SSET) ){
if( q->sclass == AUTO || q->sclass == REGISTER ){
q = &stab[id];
if( (uses&VALUSED) && !(q->sflags&SSET) ){
if( q->sclass == AUTO || q->sclass == REGISTER ){
- if( !ISARY(q->stype ) && !ISFTN(q->stype) && q->stype!=STRTY ){
+ if( !ISARY(q->stype ) && !ISFTN(q->stype) && q->stype!=STRTY
&& q->stype!=UNIONTY
){
#ifndef FLEXNAMES
werror( "%.8s may be used before set", q->sname );
#else
#ifndef FLEXNAMES
werror( "%.8s may be used before set", q->sname );
#else
@@
-514,7
+541,8
@@
efcode(){
register struct symtab *cfp;
cfp = &stab[curftn];
register struct symtab *cfp;
cfp = &stab[curftn];
- if( retstat & RETVAL ) outdef( cfp, LRV, DECTY );
+ if( retstat & RETVAL && !(Cflag && cfp->sclass==STATIC) )
+ outdef( cfp, LRV, DECTY );
if( !vflag ){
vflag = argflag;
argflag = 0;
if( !vflag ){
vflag = argflag;
argflag = 0;
@@
-562,10
+590,11
@@
aocode(p) struct symtab *p; {
}
if( p->stype == STRTY || p->stype == UNIONTY || p->stype == ENUMTY ){
}
if( p->stype == STRTY || p->stype == UNIONTY || p->stype == ENUMTY ){
+ if( !zflag && dimtab[p->sizoff+1] < 0 )
#ifndef FLEXNAMES
#ifndef FLEXNAMES
-
if( dimtab[p->sizoff+1] < 0 )
werror( "structure %.8s never defined", p->sname );
+
werror( "structure %.8s never defined", p->sname );
#else
#else
-
if( dimtab[p->sizoff+1] < 0 )
werror( "structure %s never defined", p->sname );
+
werror( "structure %s never defined", p->sname );
#endif
}
#endif
}
@@
-574,9
+603,11
@@
aocode(p) struct symtab *p; {
defnam( p ) register struct symtab *p; {
/* define the current location as the name p->sname */
defnam( p ) register struct symtab *p; {
/* define the current location as the name p->sname */
- if( p->sclass == STATIC &&
p->slevel>1
) return;
+ if( p->sclass == STATIC &&
(p->slevel>1 || Cflag)
) return;
- if( !ISFTN( p->stype ) ) outdef( p, libflag?LIB:LDI, USUAL );
+ if( !ISFTN( p->stype ) )
+ if( p->sclass == STATIC ) outdef( p, LST, USUAL );
+ else outdef( p, libflag?LIB:LDI, USUAL );
}
zecode( n ){
}
zecode( n ){
@@
-719,18
+750,24
@@
strip(s) char *s; {
static char x[BUFSIZ];
#endif
register char *p;
static char x[BUFSIZ];
#endif
register char *p;
+ static int stripping = 0;
+ if (stripping)
+ return(s);
+ stripping++;
for( p=x; *s; ++s ){
for( p=x; *s; ++s ){
- if( *s == '/' ) p=x;
- else if( *s != '"' ){
+ if( *s != '"' ){
#ifndef FLEXNAMES
/* PATCHED by ROBERT HENRY on 8Jul80 to fix 14 character file name bug */
if( p >= &x[LFNM] )
#ifndef FLEXNAMES
/* PATCHED by ROBERT HENRY on 8Jul80 to fix 14 character file name bug */
if( p >= &x[LFNM] )
- cerror( "filename too long" );
+#else
+ if( p >= &x[BUFSIZ] )
#endif
#endif
+ cerror( "filename too long" );
*p++ = *s;
}
}
*p++ = *s;
}
}
+ stripping = 0;
*p = '\0';
#ifndef FLEXNAMES
return( x );
*p = '\0';
#ifndef FLEXNAMES
return( x );
@@
-745,7
+782,7
@@
fsave( s ) char *s; {
#ifndef FLEXNAMES
if( strncmp( s, fsname.f.fn, LFNM ) ){
#else
#ifndef FLEXNAMES
if( strncmp( s, fsname.f.fn, LFNM ) ){
#else
- if
(
strcmp(s, fsname.f.fn)) {
+ if
(fsname.f.fn == NULL ||
strcmp(s, fsname.f.fn)) {
#endif
/* new one */
#ifndef FLEXNAMES
#endif
/* new one */
#ifndef FLEXNAMES
@@
-756,14
+793,21
@@
fsave( s ) char *s; {
fsname.f.decflag = LFN;
fwrite( (char *)&fsname, sizeof(fsname), 1, stdout );
#ifdef FLEXNAMES
fsname.f.decflag = LFN;
fwrite( (char *)&fsname, sizeof(fsname), 1, stdout );
#ifdef FLEXNAMES
+ /* if generating a library, prefix with the library name */
+ /* only do this for flexnames */
+ if( libname ){
+ fwrite( libname, strlen(libname), 1, stdout );
+ putchar( ':' );
+ }
fwrite( fsname.f.fn, strlen(fsname.f.fn)+1, 1, stdout );
#endif
}
}
where(f){ /* print true location of error */
fwrite( fsname.f.fn, strlen(fsname.f.fn)+1, 1, stdout );
#endif
}
}
where(f){ /* print true location of error */
- if( f == 'u' && nerrors>1 ) --nerrors; /* don't get "too many errors" */
- fprintf( stderr, "%s(%d): ", (f == 'c') ? ftitle : strip(ftitle), lineno );
+ if( f == 'u' && nerrors > 1 )
+ --nerrors; /* don't get "too many errors" */
+ fprintf( stderr, "%s(%d): ", strip(ftitle), lineno);
}
/* a number of dummy routines, unneeded by lint */
}
/* a number of dummy routines, unneeded by lint */
@@
-789,64
+833,79
@@
fldal(t) unsigned t; { /* field alignment... */
main( argc, argv ) char *argv[]; {
char *p;
main( argc, argv ) char *argv[]; {
char *p;
+ int i;
/* handle options */
/* handle options */
- for( p=argv[1]; argc>1 && *p; ++p ){
+ for( i = 1; i < argc; i++ )
+ for( p=argv[i]; *p; ++p ){
- switch( *p ){
+
switch( *p ){
- case '-':
- continue;
+
case '-':
+
continue;
- case '\0':
- break;
+ case '\0':
+ break;
+
+ case 'b':
+ brkflag = 1;
+ continue;
-
case 'b
':
-
brk
flag = 1;
- continue;
+
case 'p
':
+
p
flag = 1;
+
continue;
-
case 'p
':
-
p
flag = 1;
- continue;
+
case 'c
':
+
c
flag = 1;
+
continue;
- case 'c':
- cflag = 1;
- continue;
+ case 's':
+ /* for the moment, -s triggers -h */
- case 's':
- /* for the moment, -s triggers -h */
+ case 'h':
+ hflag = 1;
+ continue;
- case 'h':
- hflag = 1;
- continue;
+ case 'L':
+ libflag = 1;
+ case 'v':
+ vflag = 0;
+ continue;
- case 'L':
- libflag = 1;
- case 'v':
- vflag = 0;
- continue;
+ case 'x':
+ xflag = 1;
+ continue;
- case 'x':
- xflag = 1;
- continue;
+ case 'a':
+ ++aflag;
+ case 'u': /* done in second pass */
+ case 'n': /* done in shell script */
+ continue;
- case 'a':
- ++aflag;
- case 'u': /* done in second pass */
- case 'n': /* done in shell script */
- continue;
+ case 'z':
+ zflag = 1;
+ continue;
- case 't':
- werror( "option %c now default: see `man 6 lint'", *p );
- continue;
+
case 't':
+
werror( "option %c now default: see `man 6 lint'", *p );
+
continue;
- default:
- uerror( "illegal option: %c", *p );
- continue;
+ case 'P': /* debugging, done in second pass */
+ continue;
+ case 'C':
+ Cflag = 1;
+ if( p[1] ) libname = p + 1;
+ while( p[1] ) p++;
+ continue;
+
+ default:
+ uerror( "illegal option: %c", *p );
+ continue;
+
+ }
}
}
- }
if( !pflag ){ /* set sizes to sizes of target machine */
# ifdef gcos
if( !pflag ){ /* set sizes to sizes of target machine */
# ifdef gcos
@@
-880,7
+939,8
@@
ctype( type ) unsigned type; { /* are there any funny types? */
commdec( i ){
/* put out a common declaration */
commdec( i ){
/* put out a common declaration */
- outdef( &stab[i], libflag?LIB:LDC, USUAL );
+ if( stab[i].sclass == STATIC ) outdef( &stab[i], LST, USUAL );
+ else outdef( &stab[i], libflag?LIB:LDC, USUAL );
}
isitfloat ( s ) char *s; {
}
isitfloat ( s ) char *s; {
@@
-889,7
+949,7
@@
isitfloat ( s ) char *s; {
/* lint version
*/
dcon = atof( s );
/* lint version
*/
dcon = atof( s );
- return(
F
CON );
+ return(
D
CON );
}
fldcon( p ) register NODE *p; {
}
fldcon( p ) register NODE *p; {
@@
-955,6
+1015,7
@@
outdef( p, lty, mode ) struct symtab *p; {
if( mode == DECTY ) t = DECREF(t);
rc.l.type.aty = t;
rc.l.type.extra = 0;
if( mode == DECTY ) t = DECREF(t);
rc.l.type.aty = t;
rc.l.type.extra = 0;
+ rc.l.type.extra1 = 0;
astype( &rc.l.type, p->sizoff );
rc.l.nargs = (mode>USUAL) ? mode : 0;
rc.l.fline = line;
astype( &rc.l.type, p->sizoff );
rc.l.nargs = (mode>USUAL) ? mode : 0;
rc.l.fline = line;