Add Picky flag; this produces more warnings:
1. long a; int i; a = i * i; suggests casting i to long, so that we gain precision in the multiplication. 2. warns about magnitude comparisons in enums. 3. warns about possible sign extension issues when integer types become widened.
This commit is contained in:
parent
b91e1531e4
commit
3457928c2a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: err.c,v 1.37 2008/07/25 18:33:53 dsl Exp $ */
|
||||
/* $NetBSD: err.c,v 1.38 2008/07/31 15:21:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: err.c,v 1.37 2008/07/25 18:33:53 dsl Exp $");
|
||||
__RCSID("$NetBSD: err.c,v 1.38 2008/07/31 15:21:34 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -383,6 +383,7 @@ const char *msgs[] = {
|
||||
"array initializer with designators is a C9X feature", /* 321 */
|
||||
"zero sized array is a C99 extension", /* 322 */
|
||||
"continue in 'do ... while (0)' loop", /* 323 */
|
||||
"suggest cast from '%s' to '%s' on op %s to avoid overflow", /* 324 */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: externs1.h,v 1.22 2006/10/14 21:08:50 christos Exp $ */
|
||||
/* $NetBSD: externs1.h,v 1.23 2008/07/31 15:21:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -51,6 +51,7 @@ extern int yflag;
|
||||
extern int wflag;
|
||||
extern int zflag;
|
||||
extern int Sflag;
|
||||
extern int Pflag;
|
||||
|
||||
extern void norecover(void);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main1.c,v 1.18 2008/05/02 15:10:05 christos Exp $ */
|
||||
/* $NetBSD: main1.c,v 1.19 2008/07/31 15:21:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: main1.c,v 1.18 2008/05/02 15:10:05 christos Exp $");
|
||||
__RCSID("$NetBSD: main1.c,v 1.19 2008/07/31 15:21:34 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -106,6 +106,10 @@ int tflag;
|
||||
|
||||
/* Enable C9X extensions */
|
||||
int Sflag;
|
||||
|
||||
/* Picky flag */
|
||||
int Pflag;
|
||||
|
||||
/*
|
||||
* Complain about functions and external variables used and not defined,
|
||||
* or defined and not used.
|
||||
@ -142,7 +146,7 @@ main(int argc, char *argv[])
|
||||
setprogname(argv[0]);
|
||||
|
||||
ERR_ZERO(&msgset);
|
||||
while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFSX:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFPSX:")) != -1) {
|
||||
switch (c) {
|
||||
case 'a': aflag++; break;
|
||||
case 'b': bflag = 1; break;
|
||||
@ -153,6 +157,7 @@ main(int argc, char *argv[])
|
||||
case 'g': gflag = 1; break;
|
||||
case 'h': hflag = 1; break;
|
||||
case 'p': pflag = 1; break;
|
||||
case 'P': Pflag = 1; break;
|
||||
case 'r': rflag = 1; break;
|
||||
case 's': sflag = 1; break;
|
||||
case 'S': Sflag = 1; break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: print.c,v 1.3 2008/04/28 20:24:15 martin Exp $ */
|
||||
/* $NetBSD: print.c,v 1.4 2008/07/31 15:21:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: print.c,v 1.3 2008/04/28 20:24:15 martin Exp $");
|
||||
__RCSID("$NetBSD: print.c,v 1.4 2008/07/31 15:21:34 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -43,7 +43,6 @@ __RCSID("$NetBSD: print.c,v 1.3 2008/04/28 20:24:15 martin Exp $");
|
||||
#include "lint1.h"
|
||||
#include "externs1.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
static const char *str_op_t[] =
|
||||
{
|
||||
"*noop*",
|
||||
@ -129,7 +128,7 @@ prtnode(char *buf, size_t bufsiz, const tnode_t *tn)
|
||||
break;
|
||||
default:
|
||||
(void)snprintf(buf, bufsiz, v->v_ansiu ? "%llu" :
|
||||
"%lld", v->v_quad);
|
||||
"%lld", (unsigned long long)v->v_quad);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -153,4 +152,3 @@ prtnode(char *buf, size_t bufsiz, const tnode_t *tn)
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tree.c,v 1.50 2008/05/03 16:28:56 christos Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.51 2008/07/31 15:21:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: tree.c,v 1.50 2008/05/03 16:28:56 christos Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.51 2008/07/31 15:21:34 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -49,6 +49,7 @@ __RCSID("$NetBSD: tree.c,v 1.50 2008/05/03 16:28:56 christos Exp $");
|
||||
|
||||
#include "lint1.h"
|
||||
#include "cgram.h"
|
||||
#include "externs1.h"
|
||||
|
||||
/* Various flags for each operator. */
|
||||
static mod_t modtab[NOPS];
|
||||
@ -1445,12 +1446,10 @@ chkeop2(op_t op, int arg, tnode_t *ln, tnode_t *rn)
|
||||
warning(130, mp->m_name);
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
} else if (mp->m_comp && op != EQ && op != NE) {
|
||||
} else if (Pflag && mp->m_comp && op != EQ && op != NE) {
|
||||
if (eflag)
|
||||
/* dubious comparisons of enums */
|
||||
warning(243, mp->m_name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1792,15 +1791,14 @@ ptconv(int arg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
|
||||
static void
|
||||
iiconv(op_t op, int arg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
|
||||
{
|
||||
char lbuf[64], rbuf[64];
|
||||
char lbuf[64], rbuf[64], opbuf[16];
|
||||
if (tn->tn_op == CON)
|
||||
return;
|
||||
|
||||
if (op == CVT)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
if (psize(nt) > psize(ot) && isutyp(nt) != isutyp(ot)) {
|
||||
if (Pflag && psize(nt) > psize(ot) && isutyp(nt) != isutyp(ot)) {
|
||||
/* conversion to %s may sign-extend incorrectly (, arg #%d) */
|
||||
if (aflag && pflag) {
|
||||
if (op == FARG) {
|
||||
@ -1811,7 +1809,22 @@ iiconv(op_t op, int arg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Pflag && psize(nt) > psize(ot)) {
|
||||
switch (tn->tn_op) {
|
||||
case PLUS:
|
||||
case MINUS:
|
||||
case MULT:
|
||||
case SHL:
|
||||
warning(324,
|
||||
tyname(rbuf, sizeof(rbuf), gettyp(ot)),
|
||||
tyname(lbuf, sizeof(lbuf), tp),
|
||||
prtnode(opbuf, sizeof(opbuf), tn));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (psize(nt) < psize(ot) &&
|
||||
(ot == LONG || ot == ULONG || ot == QUAD || ot == UQUAD ||
|
||||
|
Loading…
Reference in New Issue
Block a user