Added tests for negative constant shifts.
[unix-history] / usr / src / old / pcc / lint / lpass1 / lint.c
index 367d916..4739160 100644 (file)
@@ -1,10 +1,10 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)lint.c     1.4     (Berkeley)      %G%";
+static char sccsid[] = "@(#)lint.c     1.8     (Berkeley)      %G%";
 #endif lint
 
 #endif lint
 
-# include "mfile1"
+# include "pass1.h"
 
 
-# include "lmanifest"
+# include "lmanifest.h"
 
 # include <ctype.h>
 
 
 # include <ctype.h>
 
@@ -283,7 +283,7 @@ lpta( p ) NODE *p; {
        t.extra = (p->in.op==ICON);
        t.extra1 = 0;
 
        t.extra = (p->in.op==ICON);
        t.extra1 = 0;
 
-       if( !astype( &t, p->in.csiz ) ) {
+       if( !astype( &t, p->fn.csiz ) ) {
                switch( t.aty ){
 
                        case CHAR:
                switch( t.aty ){
 
                        case CHAR:
@@ -651,6 +651,7 @@ clocal(p) NODE *p; {
 
        register o;
        register unsigned t, tl;
 
        register o;
        register unsigned t, tl;
+       int s;
 
        switch( o = p->in.op ){
 
 
        switch( o = p->in.op ){
 
@@ -698,6 +699,20 @@ clocal(p) NODE *p; {
                p->in.op = FREE;
                return( buildtree( o==PMCONV?MUL:DIV, p->in.left, p->in.right ) );
 
                p->in.op = FREE;
                return( buildtree( o==PMCONV?MUL:DIV, p->in.left, p->in.right ) );
 
+       case RS:
+       case LS:
+       case ASG RS:
+       case ASG LS:
+               if( p->in.right->in.op != ICON )
+                       break;
+               s = p->in.right->tn.lval;
+               if( s < 0 )
+                       werror( "negative shift" );
+               else
+               if( s >= dimtab[ p->fn.csiz ] )
+                       werror( "shift greater than size of object" );
+               break;
+
                }
 
        return(p);
                }
 
        return(p);
@@ -782,7 +797,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
@@ -949,7 +964,7 @@ isitfloat ( s ) char *s; {
        /* lint version
        */
        dcon = atof( s );
        /* lint version
        */
        dcon = atof( s );
-       return( FCON );
+       return( DCON );
        }
 
 fldcon( p ) register NODE *p; {
        }
 
 fldcon( p ) register NODE *p; {