diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2006-05-29 20:47:23 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2006-05-29 20:47:23 +0000 |
commit | 9f6721495fde3b6d8da1d395befd8d55482e4413 (patch) | |
tree | 9f9319f7b259b9150c3896e618eb7f149e13e456 | |
parent | a6e5a47fb2105d4f4fb8bab4c391f6928c937c72 (diff) |
Get rid of -t (traditional C) option. Some corrections by moritz.
-rw-r--r-- | usr.bin/xlint/lint1/cgram.y | 18 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/decl.c | 77 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/externs1.h | 3 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/func.c | 17 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/init.c | 24 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/lint.h | 4 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/main1.c | 9 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/scan.l | 48 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/tree.c | 202 | ||||
-rw-r--r-- | usr.bin/xlint/lint2/chk.c | 33 | ||||
-rw-r--r-- | usr.bin/xlint/lint2/externs2.h | 3 | ||||
-rw-r--r-- | usr.bin/xlint/lint2/main2.c | 9 | ||||
-rw-r--r-- | usr.bin/xlint/xlint/lint.1 | 28 |
13 files changed, 134 insertions, 341 deletions
diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y index d0123ebb9e3..cd88d42b921 100644 --- a/usr.bin/xlint/lint1/cgram.y +++ b/usr.bin/xlint/lint1/cgram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: cgram.y,v 1.19 2006/04/21 23:17:10 cloder Exp $ */ +/* $OpenBSD: cgram.y,v 1.20 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $ */ /* @@ -34,7 +34,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: cgram.y,v 1.19 2006/04/21 23:17:10 cloder Exp $"; +static char rcsid[] = "$OpenBSD: cgram.y,v 1.20 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdlib.h> @@ -217,7 +217,7 @@ program: if (sflag) { /* empty translation unit */ error(272); - } else if (!tflag) { + } else { /* empty translation unit */ warning(272); } @@ -282,7 +282,7 @@ data_def: T_SEMI if (sflag) { /* old style declaration; add "int" */ error(1); - } else if (!tflag) { + } else { /* old style declaration; add "int" */ warning(1); } @@ -1033,7 +1033,7 @@ vararg_parameter_type_list: if (sflag) { /* ANSI C requires formal parameter before "..." */ error(84); - } else if (!tflag) { + } else { /* ANSI C requires formal parameter before "..." */ warning(84); } @@ -1508,10 +1508,6 @@ term: $$ = build($1, $2, NULL); } | T_ADDOP term { - if (tflag && $1 == PLUS) { - /* unary + is illegal in traditional C */ - warning(100); - } $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL); } | term T_LBRACK expr T_RBRACK { @@ -1560,10 +1556,6 @@ string: string2: T_STRING { - if (tflag) { - /* concatenated strings are illegal in traditional C */ - warning(219); - } $$ = $1; } | string2 T_STRING { diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index efbc2eaf7ee..fad3a290224 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: decl.c,v 1.22 2006/05/05 06:47:28 otto Exp $ */ +/* $OpenBSD: decl.c,v 1.23 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: decl.c,v 1.22 2006/05/05 06:47:28 otto Exp $"; +static char rcsid[] = "$OpenBSD: decl.c,v 1.23 2006/05/29 20:47:22 cloder Exp $"; #endif #include <sys/param.h> @@ -373,7 +373,7 @@ addtype(type_t *tp) dcs->d_lmod = NOTSPEC; if (!quadflg) /* %s C does not support 'long long' */ - (void)gnuism(265, tflag ? "traditional" : "ANSI"); + (void)gnuism(265, "ANSI"); } if (dcs->d_type != NULL && dcs->d_type->t_typedef) { @@ -429,9 +429,8 @@ tdeferr(type_t *td, tspec_t t) case UNSIGN: if (t2 == CHAR || t2 == SHORT || t2 == INT || t2 == LONG || t2 == QUAD) { - if (!tflag) - /* modifying typedef with ... */ - warning(5, ttab[t].tt_name); + /* modifying typedef with ... */ + warning(5, ttab[t].tt_name); td = duptyp(gettyp(mrgtspec(t2, t))); td->t_typedef = 1; return (td); @@ -714,18 +713,14 @@ deftyp(void) if (l == LONG) { l = NOTSPEC; t = DOUBLE; - if (!tflag) - /* use 'double' instead of ... */ - warning(6); + /* use 'double' instead of ... */ + warning(6); } break; case DOUBLE: if (l == LONG) { l = NOTSPEC; t = LDOUBLE; - if (tflag) - /* 'long double' is illegal in ... */ - warning(266); } break; case VOID: @@ -948,7 +943,7 @@ chktyp(sym_t *sym) } return; } else if (tp->t_const || tp->t_volatile) { - if (sflag) { /* XXX oder better !tflag ? */ + if (sflag) { /* function cannot return const... */ warning(228); } @@ -1285,9 +1280,6 @@ addfunc(sym_t *decl, sym_t *args) type_t **tpp, *tp; if (dcs->d_proto) { - if (tflag) - /* function prototypes are illegal in traditional C */ - warning(270); args = nsfunc(decl, args); } else { osfunc(decl, args); @@ -1565,7 +1557,7 @@ mktag(sym_t *tag, tspec_t kind, int decl, int semi) /* a new tag, no empty declaration */ dcs->d_nxt->d_nedecl = 1; if (scl == ENUMTAG && !decl) { - if (!tflag && (sflag || pflag)) + if (sflag || pflag) /* forward reference to enum type */ warning(42); } @@ -1616,15 +1608,10 @@ newtag(sym_t *tag, scl_t scl, int decl, int semi) if (tag->s_blklev < blklev) { if (semi) { /* "struct a;" */ - if (!tflag) { - if (!sflag) - /* decl. introduces new type ... */ - warning(44, scltoa(scl), tag->s_name); - tag = pushdown(tag); - } else if (tag->s_scl != scl) { - /* base type is really "%s %s" */ - warning(45, scltoa(tag->s_scl), tag->s_name); - } + if (!sflag) + /* decl. introduces new type ... */ + warning(44, scltoa(scl), tag->s_name); + tag = pushdown(tag); dcs->d_nxt->d_nedecl = 1; } else if (decl) { /* "struct a { ..." */ @@ -2001,25 +1988,25 @@ eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *warn) } else if (t == CHAR || t == SCHAR) { t = INT; } else if (t == UCHAR) { - t = tflag ? UINT : INT; + t = INT; } else if (t == SHORT) { t = INT; } else if (t == USHORT) { /* CONSTCOND */ - t = INT_MAX < USHRT_MAX || tflag ? UINT : INT; + t = INT_MAX < USHRT_MAX ? UINT : INT; } } if (t != tp2->t_tspec) return (0); - if (tp1->t_const != tp2->t_const && !ignqual && !tflag) + if (tp1->t_const != tp2->t_const && !ignqual) return (0); - if (tp1->t_volatile != tp2->t_volatile && !ignqual && !tflag) + if (tp1->t_volatile != tp2->t_volatile && !ignqual) return (0); - if (tp1->t_restrict != tp2->t_restrict && !ignqual && !tflag) + if (tp1->t_restrict != tp2->t_restrict && !ignqual) return (0); if (t == STRUCT || t == UNION) @@ -2031,7 +2018,7 @@ eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *warn) } /* dont check prototypes for traditional */ - if (t == FUNC && !tflag) { + if (t == FUNC) { if (tp1->t_proto && tp2->t_proto) { if (!eqargs(tp1, tp2, warn)) return (0); @@ -2240,13 +2227,7 @@ decl1arg(sym_t *sym, int initflg) if ((t = sym->s_type->t_tspec) == ARRAY) { sym->s_type = incref(sym->s_type->t_subt, PTR); } else if (t == FUNC) { - if (tflag) - /* a function is declared as an argument: %s */ - warning(50, sym->s_name); sym->s_type = incref(sym->s_type, PTR); - } else if (t == FLOAT) { - if (tflag) - sym->s_type = gettyp(DOUBLE); } if (dcs->d_inline) @@ -2457,8 +2438,6 @@ decl1loc(sym_t *dsym, int initflg) * functions may be declared inline at local scope, although * this has no effect for a later definition of the same * function. - * XXX it should have an effect if tflag is set. this would - * also be the way gcc behaves. */ if (dcs->d_inline) { if (dsym->s_type->t_tspec == FUNC) { @@ -2518,15 +2497,9 @@ decl1loc(sym_t *dsym, int initflg) /* no hflag, because its illegal! */ if (dcs->d_rdcsym->s_arg) { /* - * if !tflag, a "redeclaration of %s" error + * a "redeclaration of %s" error * is produced below */ - if (tflag) { - if (hflag) - /* decl. hides parameter: %s */ - warning(91, dsym->s_name); - rmsym(dcs->d_rdcsym); - } } } else if (dcs->d_rdcsym->s_blklev < blklev) { @@ -2724,11 +2697,7 @@ chksz(sym_t *dsym) if (length(dsym->s_type, dsym->s_name) == 0 && dsym->s_type->t_tspec == ARRAY && dsym->s_type->t_dim == 0) { /* empty array declaration: %s */ - if (tflag) { - warning(190, dsym->s_name); - } else { - error(190, dsym->s_name); - } + error(190, dsym->s_name); } } @@ -3016,7 +2985,7 @@ chkglvar(sym_t *sym) warning(307, sym->s_name); } } - if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) { + if (sym->s_def == TDEF && sym->s_type->t_const) { STRUCT_ASSIGN(curr_pos, sym->s_dpos); /* const object %s should have initializer */ warning(227, sym->s_name); @@ -3038,7 +3007,7 @@ glchksz(sym_t *sym) if (length(sym->s_type, sym->s_name) == 0 && sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) { /* empty array declaration: %s */ - if (tflag || (sym->s_scl == EXTERN && !sflag)) { + if (sym->s_scl == EXTERN && !sflag) { warning(190, sym->s_name); } else { error(190, sym->s_name); diff --git a/usr.bin/xlint/lint1/externs1.h b/usr.bin/xlint/lint1/externs1.h index 9d96f353203..437c0d8eb93 100644 --- a/usr.bin/xlint/lint1/externs1.h +++ b/usr.bin/xlint/lint1/externs1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs1.h,v 1.14 2006/05/28 23:50:54 cloder Exp $ */ +/* $OpenBSD: externs1.h,v 1.15 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: externs1.h,v 1.7 1995/10/02 17:31:39 jpo Exp $ */ /* @@ -45,7 +45,6 @@ extern int hflag; extern int pflag; extern int rflag; extern int sflag; -extern int tflag; extern int uflag; extern int vflag; extern int yflag; diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c index cca33022fea..3b90b1d417e 100644 --- a/usr.bin/xlint/lint1/func.c +++ b/usr.bin/xlint/lint1/func.c @@ -1,4 +1,4 @@ -/* $OpenBSD: func.c,v 1.17 2006/05/28 23:50:54 cloder Exp $ */ +/* $OpenBSD: func.c,v 1.18 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: func.c,v 1.17 2006/05/28 23:50:54 cloder Exp $"; +static char rcsid[] = "$OpenBSD: func.c,v 1.18 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdlib.h> @@ -481,12 +481,6 @@ label(int typ, sym_t *sym, tnode_t *tn) } t = tn->tn_type->t_tspec; - if (t == LONG || t == ULONG || - t == QUAD || t == UQUAD) { - if (tflag) - /* case label must be of type ... */ - warning(203); - } /* * get the value of the expression and convert it @@ -604,13 +598,6 @@ switch1(tnode_t *tn) error(205); tn = NULL; } - if (tn != NULL && tflag) { - t = tn->tn_type->t_tspec; - if (t == LONG || t == ULONG || t == QUAD || t == UQUAD) { - /* switch expr. must be of type `int' in trad. C */ - warning(271); - } - } /* * Remember the type of the expression. Because its possible diff --git a/usr.bin/xlint/lint1/init.c b/usr.bin/xlint/lint1/init.c index 65d77f823c2..4fc2e6cf0a9 100644 --- a/usr.bin/xlint/lint1/init.c +++ b/usr.bin/xlint/lint1/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.9 2006/05/05 06:46:17 otto Exp $ */ +/* $OpenBSD: init.c,v 1.10 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: init.c,v 1.4 1995/10/02 17:21:37 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: init.c,v 1.9 2006/05/05 06:46:17 otto Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.10 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdlib.h> @@ -200,9 +200,6 @@ pushinit(void) istk->i_cnt = istk->i_type->t_dim; break; case UNION: - if (tflag) - /* initialisation of union is illegal in trad. C */ - warning(238); /* FALLTHROUGH */ case STRUCT: if (incompl(istk->i_type)) { @@ -307,13 +304,6 @@ initlbr(void) if (initerr) return; - if ((initsym->s_scl == AUTO || initsym->s_scl == REG) && - initstk->i_nxt == NULL) { - if (tflag && !issclt(initstk->i_subt->t_tspec)) - /* no automatic aggregate initialization in trad. C*/ - warning(188); - } - /* * Remove all entries which cannot be used for further initializers * and do not expect a closing brace. @@ -411,16 +401,6 @@ mkinit(tnode_t *tn) expr(tn, 1, 0); trestor(tmem); - if (isityp(lt) && ln->tn_type->t_isfield && !isityp(rt)) { - /* - * Bit-fields can be initialized in trad. C only by integer - * constants. - */ - if (tflag) - /* bit-field initialisation is illegal in trad. C */ - warning(186); - } - if (lt != rt || (initstk->i_type->t_isfield && tn->tn_op == CON)) tn = convert(INIT, NULL, initstk->i_type, tn); diff --git a/usr.bin/xlint/lint1/lint.h b/usr.bin/xlint/lint1/lint.h index 4948c59290c..8ecadbee938 100644 --- a/usr.bin/xlint/lint1/lint.h +++ b/usr.bin/xlint/lint1/lint.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lint.h,v 1.5 2006/04/25 01:25:41 cloder Exp $ */ +/* $OpenBSD: lint.h,v 1.6 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: lint.h,v 1.2 1995/07/03 21:24:18 cgd Exp $ */ /* @@ -57,7 +57,7 @@ typedef enum { QUAD, /* (signed) long long */ UQUAD, /* unsigned long long */ FLOAT, /* float */ - DOUBLE, /* double or, with tflag, long float */ + DOUBLE, /* double */ LDOUBLE, /* long double */ VOID, /* void */ STRUCT, /* structure tag */ diff --git a/usr.bin/xlint/lint1/main1.c b/usr.bin/xlint/lint1/main1.c index 3952a5de9c0..a8f133df747 100644 --- a/usr.bin/xlint/lint1/main1.c +++ b/usr.bin/xlint/lint1/main1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main1.c,v 1.10 2006/05/28 23:50:54 cloder Exp $ */ +/* $OpenBSD: main1.c,v 1.11 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: main1.c,v 1.10 2006/05/28 23:50:54 cloder Exp $"; +static char rcsid[] = "$OpenBSD: main1.c,v 1.11 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdio.h> @@ -82,9 +82,6 @@ int rflag; /* Strict ANSI C mode. */ int sflag; -/* Traditional C mode. */ -int tflag; - /* * Complain about functions and external variables used and not defined, * or defined and not used. @@ -118,7 +115,7 @@ main(int argc, char *argv[]) case 'p': pflag = 1; break; case 'r': rflag = 1; break; case 's': sflag = 1; break; - case 't': tflag = 1; break; + case 't': /* obsolete */ break; case 'u': uflag = 0; break; case 'v': vflag = 0; break; case 'y': yflag = 1; break; diff --git a/usr.bin/xlint/lint1/scan.l b/usr.bin/xlint/lint1/scan.l index 96a9ce5e7dd..bd9be5ec642 100644 --- a/usr.bin/xlint/lint1/scan.l +++ b/usr.bin/xlint/lint1/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.29 2006/04/20 16:29:48 cloder Exp $ */ +/* $OpenBSD: scan.l,v 1.30 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $ */ /* @@ -34,7 +34,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: scan.l,v 1.29 2006/04/20 16:29:48 cloder Exp $"; +static char rcsid[] = "$OpenBSD: scan.l,v 1.30 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdlib.h> @@ -280,8 +280,6 @@ initscan(void) u_quad_t uq; for (kw = kwtab; kw->kw_name != NULL; kw++) { - if (kw->kw_stdc && tflag) - continue; if (kw->kw_gcc && !gflag) continue; sym = getblk(sizeof (sym_t)); @@ -499,10 +497,6 @@ icon(int base) if (u_suffix > 1) u_suffix = 1; } - if (tflag && u_suffix != 0) { - /* suffix U is illegal in traditional C */ - warning(97); - } typ = contypes[u_suffix][l_suffix]; errno = 0; @@ -534,9 +528,7 @@ icon(int base) typ = ULONG; } if (typ == UINT || typ == ULONG) { - if (tflag) { - typ = LONG; - } else if (!sflag) { + if (!sflag) { /* * Remember that the constant is unsigned * only in ANSI C @@ -550,14 +542,14 @@ icon(int base) typ = ULONG; break; case LONG: - if (ul > LONG_MAX && !tflag) { + if (ul > LONG_MAX) { typ = ULONG; if (!sflag) ansiu = 1; } break; case QUAD: - if (uq > QUAD_MAX && !tflag) { + if (uq > QUAD_MAX) { typ = UQUAD; if (!sflag) ansiu = 1; @@ -652,11 +644,6 @@ fcon(void) typ = DOUBLE; } - if (tflag && typ != DOUBLE) { - /* suffixes F and L are illegal in traditional C */ - warning(98); - } - errno = 0; d = strtod(cp, &eptr); if (eptr != cp + len) @@ -714,11 +701,6 @@ fhexcon(void) typ = DOUBLE; } - if (tflag) { - /* hex float constant are only legal in C99 */ - warning(314); - } - /* arbitrary value, until strtod can cope */ d = 1.0; @@ -866,23 +848,14 @@ getescc(int d) case '\\': switch (c = inpc()) { case '"': - if (tflag && d == '\'') - /* \" inside character constant undef. ... */ - warning(262); return ('"'); case '\'': return ('\''); case '?': - if (tflag) - /* \? undefined in traditional C */ - warning(263); return ('?'); case '\\': return ('\\'); case 'a': - if (tflag) - /* \a undefined in traditional C */ - warning(81); return ('\a'); case 'b': return ('\b'); @@ -895,9 +868,6 @@ getescc(int d) case 't': return ('\t'); case 'v': - if (tflag) - /* \v undefined in traditional C */ - warning(264); return ('\v'); case '8': case '9': /* bad octal digit %c */ @@ -910,10 +880,7 @@ getescc(int d) do { v = (v << 3) + (c - '0'); c = inpc(); - } while (--n && isdigit(c) && (tflag || c <= '7')); - if (tflag && n > 0 && isdigit(c)) - /* bad octal digit %c */ - warning(77, c); + } while (--n && isdigit(c) && (c <= '7')); pbc = c; if (v > UCHAR_MAX) { /* character escape does not fit in char. */ @@ -922,9 +889,6 @@ getescc(int d) } return (v); case 'x': - if (tflag) - /* \x undefined in traditional C */ - warning(82); v = 0; n = 0; while ((c = inpc()) >= 0 && isxdigit(c)) { diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index 4a10ab94806..0362ce0d33e 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tree.c,v 1.41 2006/05/28 23:42:49 cloder Exp $ */ +/* $OpenBSD: tree.c,v 1.42 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: tree.c,v 1.12 1995/10/02 17:37:57 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: tree.c,v 1.41 2006/05/28 23:42:49 cloder Exp $"; +static char rcsid[] = "$OpenBSD: tree.c,v 1.42 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdlib.h> @@ -298,10 +298,6 @@ getnnode(sym_t *sym, int ntok) /* function implicitly declared to ... */ warning(215); } - /* - * XXX if tflag is set the symbol should be - * exported to level 0 - */ sym->s_type = incref(sym->s_type, FUNC); } else { /* %s undefined */ @@ -477,11 +473,7 @@ strmemb(tnode_t *tn, op_t op, sym_t *msym) */ if (str != NULL) { /* illegal member use: %s */ - if (eq && tflag) { - warning(102, msym->s_name); - } else { - error(102, msym->s_name); - } + error(102, msym->s_name); return (msym); } @@ -492,27 +484,14 @@ strmemb(tnode_t *tn, op_t op, sym_t *msym) if (eq) { if (op == POINT) { /* left operand of "." must be struct/union object */ - if (tflag) { - warning(103); - } else { - error(103); - } + error(103); } else { /* left operand of "->" must be pointer to ... */ - if (tflag && tn->tn_type->t_tspec == PTR) { - warning(104); - } else { - error(104); - } + error(104); } } else { - if (tflag) { - /* non-unique member requires struct/union %s */ - error(105, op == POINT ? "object" : "pointer"); - } else { - /* unacceptable operand of %s */ - error(111, modtab[op].m_name); - } + /* unacceptable operand of %s */ + error(111, modtab[op].m_name); } return (msym); @@ -593,7 +572,7 @@ build(op_t op, tnode_t *ln, tnode_t *rn) } /* Make sure both operands are of the same type */ - if (mp->m_balance || (tflag && (op == SHL || op == SHR))) + if (mp->m_balance) balance(op, &ln, &rn); /* @@ -807,20 +786,14 @@ typeok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) */ if (lt == FUNC || lt == VOID || ltp->t_isfield || ((lt != STRUCT && lt != UNION) && !ln->tn_lvalue)) { - /* Without tflag we already have an error */ - if (tflag) - /* unacceptable operand of %s */ - error(111, mp->m_name); + /* we already have an error from strmemb() */ return (0); } /* Now we have an object we can create a pointer to */ break; case ARROW: - if (lt != PTR && !(tflag && isityp(lt))) { - /* Without tflag we already have an error */ - if (tflag) - /* unacceptable operand of %s */ - error(111, mp->m_name); + if (lt != PTR) { + /* we already have an error from strmemb() */ return (0); } break; @@ -840,8 +813,7 @@ typeok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) return (0); } else if (ltp->t_const) { /* %soperand of %s must be modifiable lvalue */ - if (!tflag) - warning(115, "", mp->m_name); + warning(115, "", mp->m_name); } break; case AMPER: @@ -918,7 +890,7 @@ typeok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) } else if (ln->tn_val->v_quad < 0) { warning(120); } - } else if (!tflag && !sflag && !isutyp(olt) && isutyp(ort)) { + } else if (!sflag && !isutyp(olt) && isutyp(ort)) { /* * The left operand would become unsigned in * traditional C. @@ -928,7 +900,7 @@ typeok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) /* semantics of %s change in ANSI C; use ... */ warning(118, mp->m_name); } - } else if (!tflag && !sflag && !isutyp(olt) && !isutyp(ort) && + } else if (!sflag && !isutyp(olt) && !isutyp(ort) && psize(lt) < psize(rt)) { /* * In traditional C the left operand would be extended, @@ -1094,7 +1066,7 @@ typeok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) case SHLASS: goto assign; case SHRASS: - if (pflag && !isutyp(lt) && !(tflag && isutyp(rt))) { + if (pflag && !isutyp(lt)) { /* bitwise operation on s.v. possibly nonportable */ warning(117); } @@ -1121,8 +1093,7 @@ typeok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) } else if (ltp->t_const || ((lt == STRUCT || lt == UNION) && conmemb(ltp))) { /* %soperand of %s must be modifiable lvalue */ - if (!tflag) - warning(115, "left ", mp->m_name); + warning(115, "left ", mp->m_name); } break; case COMMA: @@ -1246,8 +1217,7 @@ asgntypok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn) if (lt == PTR && rt == PTR && (lst == VOID || rst == VOID || eqtype(lstp, rstp, 1, 0, NULL))) { /* compatible pointer types (qualifiers ignored) */ - if (!tflag && - ((!lstp->t_const && rstp->t_const) || + if (((!lstp->t_const && rstp->t_const) || (!lstp->t_volatile && rstp->t_volatile))) { /* left side has not all qualifiers of right */ switch (op) { @@ -1473,9 +1443,8 @@ mktnode(op_t op, type_t *type, tnode_t *ln, tnode_t *rn) /* * Performs usual conversion of operands to (unsigned) int. * - * If tflag is set or the operand is a function argument with no - * type information (no prototype or variable # of args), convert - * float to double. + * If the operand is a function argument with no type information + * (no prototype or variable # of args), convert float to double. */ tnode_t * promote(op_t op, int farg, tnode_t *tn) @@ -1489,50 +1458,34 @@ promote(op_t op, int farg, tnode_t *tn) if (!isatyp(t)) return (tn); - if (!tflag) { - /* - * ANSI C requires that the result is always of type INT - * if INT can represent all possible values of the previous - * type. - */ - if (tn->tn_type->t_isfield) { - len = tn->tn_type->t_flen; - if (size(INT) > len) { - t = INT; + /* + * ANSI C requires that the result is always of type INT + * if INT can represent all possible values of the previous + * type. + */ + if (tn->tn_type->t_isfield) { + len = tn->tn_type->t_flen; + if (size(INT) > len) { + t = INT; + } else { + if (size(INT) != len) + lerror("promote() 1"); + if (isutyp(t)) { + t = UINT; } else { - if (size(INT) != len) - lerror("promote() 1"); - if (isutyp(t)) { - t = UINT; - } else { - t = INT; - } + t = INT; } - } else if (t == CHAR || t == UCHAR || t == SCHAR) { - t = (size(CHAR) < size(INT) || t != UCHAR) ? - INT : UINT; - } else if (t == SHORT || t == USHORT) { - t = (size(SHORT) < size(INT) || t == SHORT) ? - INT : UINT; - } else if (t == ENUM) { - t = INT; - } else if (farg && t == FLOAT) { - t = DOUBLE; - } - } else { - /* - * In traditional C, keep unsigned and promote FLOAT - * to DOUBLE. - */ - if (t == UCHAR || t == USHORT) { - t = UINT; - } else if (t == CHAR || t == SCHAR || t == SHORT) { - t = INT; - } else if (t == FLOAT) { - t = DOUBLE; - } else if (t == ENUM) { - t = INT; } + } else if (t == CHAR || t == UCHAR || t == SCHAR) { + t = (size(CHAR) < size(INT) || t != UCHAR) ? + INT : UINT; + } else if (t == SHORT || t == USHORT) { + t = (size(SHORT) < size(INT) || t == SHORT) ? + INT : UINT; + } else if (t == ENUM) { + t = INT; + } else if (farg && t == FLOAT) { + t = DOUBLE; } if (t != tn->tn_type->t_tspec) { @@ -1568,46 +1521,34 @@ balance(op_t op, tnode_t **lnp, tnode_t **rnp) if (!isatyp(lt) || !isatyp(rt)) return; - if (!tflag) { - if (lt == rt) { + if (lt == rt) { + t = lt; + } else if (lt == LDOUBLE || rt == LDOUBLE) { + t = LDOUBLE; + } else if (lt == DOUBLE || rt == DOUBLE) { + t = DOUBLE; + } else if (lt == FLOAT || rt == FLOAT) { + t = FLOAT; + } else { + /* + * If type A has more bits than type B it should + * be able to hold all possible values of type B. + */ + if (size(lt) > size(rt)) { t = lt; - } else if (lt == LDOUBLE || rt == LDOUBLE) { - t = LDOUBLE; - } else if (lt == DOUBLE || rt == DOUBLE) { - t = DOUBLE; - } else if (lt == FLOAT || rt == FLOAT) { - t = FLOAT; + } else if (size(lt) < size(rt)) { + t = rt; } else { - /* - * If type A has more bits than type B it should - * be able to hold all possible values of type B. - */ - if (size(lt) > size(rt)) { - t = lt; - } else if (size(lt) < size(rt)) { - t = rt; - } else { - for (i = 3; tl[i] != INT; i++) { - if (tl[i] == lt || tl[i] == rt) - break; - } - if ((isutyp(lt) || isutyp(rt)) && - !isutyp(tl[i])) { - i--; - } - t = tl[i]; + for (i = 3; tl[i] != INT; i++) { + if (tl[i] == lt || tl[i] == rt) + break; } + if ((isutyp(lt) || isutyp(rt)) && + !isutyp(tl[i])) { + i--; + } + t = tl[i]; } - } else { - /* Keep unsigned in traditional C */ - u = isutyp(lt) || isutyp(rt); - for (i = 0; tl[i] != INT; i++) { - if (lt == tl[i] || rt == tl[i]) - break; - } - t = tl[i]; - if (u && isityp(t) && !isutyp(t)) - t = utyp(t); } if (t != lt) { @@ -1641,7 +1582,7 @@ convert(op_t op, farg_t *farg, type_t *tp, tnode_t *tn) if ((ot = tn->tn_type->t_tspec) == PTR) ost = tn->tn_type->t_subt->t_tspec; - if (!tflag && !sflag && op == FARG) + if (!sflag && op == FARG) ptconv(farg, nt, ot, tp, tn); if (isityp(nt) && isityp(ot)) { iiconv(op, farg, nt, ot, tp, tn); @@ -2290,8 +2231,7 @@ bldstr(op_t op, tnode_t *ln, tnode_t *rn) if (op == POINT) { ln = bldamper(ln, 1); } else if (ln->tn_type->t_tspec != PTR) { - if (!tflag || !isityp(ln->tn_type->t_tspec)) - lerror("bldstr() 4"); + lerror("bldstr() 4"); ln = convert(NOOP, NULL, tincref(gettyp(VOID), PTR), ln); } @@ -2349,8 +2289,6 @@ bldamper(tnode_t *tn, int noign) if (!noign && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) { /* & before array or function: ignored */ - if (tflag) - warning(127); return (tn); } diff --git a/usr.bin/xlint/lint2/chk.c b/usr.bin/xlint/lint2/chk.c index fe9bc37d30f..23b7bfb1a10 100644 --- a/usr.bin/xlint/lint2/chk.c +++ b/usr.bin/xlint/lint2/chk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chk.c,v 1.13 2006/04/25 01:25:41 cloder Exp $ */ +/* $OpenBSD: chk.c,v 1.14 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: chk.c,v 1.2 1995/07/03 21:24:42 cgd Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: chk.c,v 1.13 2006/04/25 01:25:41 cloder Exp $"; +static char rcsid[] = "$OpenBSD: chk.c,v 1.14 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdlib.h> @@ -595,12 +595,12 @@ chkau(hte_t *hte, int n, sym_t *def, sym_t *decl, pos_t *pos1p, } else if (t1 == CHAR || t1 == SCHAR) { t1 = INT; } else if (t1 == UCHAR) { - t1 = tflag ? UINT : INT; + t1 = INT; } else if (t1 == SHORT) { t1 = INT; } else if (t1 == USHORT) { /* CONSTCOND */ - t1 = INT_MAX < USHRT_MAX || tflag ? UINT : INT; + t1 = INT_MAX < USHRT_MAX ? UINT : INT; } } @@ -842,8 +842,8 @@ printflike(hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap) inconarg(hte, call, n); } } else if (fc == 'D' || fc == 'O' || fc == 'U') { - if ((alt && fc != 'O') || sz != NOTSPEC || !tflag) - badfmt(hte, call); + /* DOU are deprecated */ + badfmt(hte, call); sz = LONG; if (fc == 'D') { goto int_conv; @@ -1000,13 +1000,11 @@ scanflike(hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap) } goto conv; } else if (fc == 'D') { - if (sz != NOTSPEC || !tflag) - badfmt(hte, call); + badfmt(hte, call); sz = LONG; goto conv; } else if (fc == 'O') { - if (sz != NOTSPEC || !tflag) - badfmt(hte, call); + badfmt(hte, call); sz = ULONG; goto conv; } else if (fc == 'X') { @@ -1014,8 +1012,7 @@ scanflike(hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap) * XXX valid in ANSI C, but in NetBSD's libc imple- * mented as "lx". Thats why it should be avoided. */ - if (sz != NOTSPEC || !tflag) - badfmt(hte, call); + badfmt(hte, call); sz = ULONG; goto conv; } else if (fc == 'E') { @@ -1023,14 +1020,12 @@ scanflike(hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap) * XXX valid in ANSI C, but in NetBSD's libc imple- * mented as "lf". Thats why it should be avoided. */ - if (sz != NOTSPEC || !tflag) - badfmt(hte, call); + badfmt(hte, call); sz = DOUBLE; goto conv; } else if (fc == 'F') { /* XXX only for backward compatibility */ - if (sz != NOTSPEC || !tflag) - badfmt(hte, call); + badfmt(hte, call); sz = DOUBLE; goto conv; } else if (fc == 'G') { @@ -1273,12 +1268,12 @@ eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int asgn, int *warn) } else if (t == CHAR || t == SCHAR) { t = INT; } else if (t == UCHAR) { - t = tflag ? UINT : INT; + t = INT; } else if (t == SHORT) { t = INT; } else if (t == USHORT) { /* CONSTCOND */ - t = INT_MAX < USHRT_MAX || tflag ? UINT : INT; + t = INT_MAX < USHRT_MAX ? UINT : INT; } } @@ -1318,7 +1313,7 @@ eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int asgn, int *warn) return (0); if (!tp1->t_volatile && tp2->t_volatile) return (0); - } else if (!ignqual && !tflag) { + } else if (!ignqual) { if (tp1->t_const != tp2->t_const) return (0); if (tp1->t_const != tp2->t_const) diff --git a/usr.bin/xlint/lint2/externs2.h b/usr.bin/xlint/lint2/externs2.h index 1b6a97f5fc0..0e54ce8dabe 100644 --- a/usr.bin/xlint/lint2/externs2.h +++ b/usr.bin/xlint/lint2/externs2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs2.h,v 1.5 2005/12/01 05:06:40 cloder Exp $ */ +/* $OpenBSD: externs2.h,v 1.6 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: externs2.h,v 1.2 1995/07/03 21:24:46 cgd Exp $ */ /* @@ -41,7 +41,6 @@ extern int Cflag; extern const char *libname; extern int pflag; extern int sflag; -extern int tflag; extern int Hflag; extern int hflag; extern int Fflag; diff --git a/usr.bin/xlint/lint2/main2.c b/usr.bin/xlint/lint2/main2.c index 20e272d1b5e..6db5895a93a 100644 --- a/usr.bin/xlint/lint2/main2.c +++ b/usr.bin/xlint/lint2/main2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main2.c,v 1.8 2005/11/23 18:21:44 deraadt Exp $ */ +/* $OpenBSD: main2.c,v 1.9 2006/05/29 20:47:22 cloder Exp $ */ /* $NetBSD: main2.c,v 1.2 1995/07/03 21:24:53 cgd Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: main2.c,v 1.8 2005/11/23 18:21:44 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: main2.c,v 1.9 2006/05/29 20:47:22 cloder Exp $"; #endif #include <stdio.h> @@ -64,8 +64,6 @@ int pflag; */ int sflag; -int tflag; - /* * If a complaint stems from a included file, print the name of the included * file instead of the name spezified at the command line followed by '?' @@ -102,9 +100,6 @@ main(int argc, char *argv[]) case 's': sflag = 1; break; - case 't': - tflag = 1; - break; case 'u': uflag = 0; break; diff --git a/usr.bin/xlint/xlint/lint.1 b/usr.bin/xlint/xlint/lint.1 index 9d6ef92d6f6..54ef6af779c 100644 --- a/usr.bin/xlint/xlint/lint.1 +++ b/usr.bin/xlint/xlint/lint.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: lint.1,v 1.21 2006/05/29 10:35:17 jmc Exp $ +.\" $OpenBSD: lint.1,v 1.22 2006/05/29 20:47:22 cloder Exp $ .\" $NetBSD: lint.1,v 1.3 1995/10/23 13:45:31 jpo Exp $ .\" .\" Copyright (c) 1994, 1995 Jochen Pohl @@ -38,8 +38,7 @@ .Nd a C program verifier .Sh SYNOPSIS .Nm lint -.Op Fl cefghprvxzHFV -.Op Fl s Ns | Ns Fl t +.Op Fl cefghprsvxzHFV .Op Fl i Ns | Ns Fl nu .Op Fl D Ns Ar name Ns Op =def .Op Fl U Ns Ar name @@ -49,8 +48,7 @@ .Op Fl o Ns Ar outputfile .Ar .Nm lint -.Op Fl cefghprvzHFV -.Op Fl s Ns | Ns Fl t +.Op Fl cefghprsvzHFV .Fl C Ns Ar library .Op Fl D Ns Ar name Ns Op =def .Op Fl I Ns Ar directory @@ -214,26 +212,6 @@ With the flag, .Li __STRICT_ANSI__ is a predefined preprocessor macro. -.It Fl t -Traditional C mode. -.Li __STDC__ -is not predefined in this mode. -Warnings are printed for constructs not allowed in -traditional C. -Warnings for constructs which behave differently in -traditional C and ANSI C are suppressed. -Preprocessor macros describing the machine type (e.g., -.Li sun3 ) -and machine architecture (e.g., -.Li m68k ) -are defined without leading and trailing underscores. -The keywords -.Sy const , -.Sy volatile -and -.Sy signed -are not available in traditional C mode (although the alternate -keywords with leading underscores still are). .It Fl u Do not complain about functions and external variables used and not defined, or defined and not used (this is suitable |