Module Name: src
Committed By: rillig
Date: Sat Apr 30 21:38:03 UTC 2022
Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h func.c init.c lex.c
main1.c tree.c
Log Message:
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but
there is only a single mode in which allow_c90 is false, therefore it
suffices to test only that.
While double-checking each occurrence of tflag individually, I learned
why lint performs lookups of struct members only by name, independently
of the struct in which they are declared. See typeok_arrow for details.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.408 -r1.409 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.278 -r1.279 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.233 -r1.234 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.437 -r1.438 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.408 src/usr.bin/xlint/lint1/cgram.y:1.409
--- src/usr.bin/xlint/lint1/cgram.y:1.408 Sat Apr 30 19:18:48 2022
+++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 30 21:38:03 2022
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.408 2022/04/30 19:18:48 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.409 2022/04/30 21:38:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.408 2022/04/30 19:18:48 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.409 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <limits.h>
@@ -375,7 +375,7 @@ program:
if (sflag) {
/* empty translation unit */
error(272);
- } else if (!tflag) {
+ } else if (allow_c90) {
/* empty translation unit */
warning(272);
}
@@ -405,7 +405,7 @@ identifier:
string:
T_STRING
| string T_STRING {
- if (tflag) {
+ if (!allow_c90) {
/* concatenated strings are illegal in traditional C */
warning(219);
}
@@ -590,7 +590,7 @@ unary_expression:
$$ = build_unary(INDIR, $2, $3);
}
| T_ADDITIVE sys cast_expression {
- if (tflag && $1 == PLUS) {
+ if (!allow_c90 && $1 == PLUS) {
/* unary + is illegal in traditional C */
warning(100);
}
@@ -1485,7 +1485,7 @@ vararg_parameter_type_list: /* specific
if (sflag) {
/* ANSI C requires formal parameter before '...' */
error(84);
- } else if (!tflag) {
+ } else if (allow_c90) {
/* ANSI C requires formal parameter before '...' */
warning(84);
}
@@ -1922,7 +1922,7 @@ external_declaration: /* C99 6.9 */
if (sflag) {
/* empty declaration */
error(0);
- } else if (!tflag) {
+ } else if (allow_c90) {
/* empty declaration */
warning(0);
}
@@ -1943,7 +1943,7 @@ top_level_declaration: /* C99 6.9 calls
if (sflag) {
/* old style declaration; add 'int' */
error(1);
- } else if (!tflag) {
+ } else if (allow_c90) {
/* old style declaration; add 'int' */
warning(1);
}
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.278 src/usr.bin/xlint/lint1/decl.c:1.279
--- src/usr.bin/xlint/lint1/decl.c:1.278 Sat Apr 16 19:18:17 2022
+++ src/usr.bin/xlint/lint1/decl.c Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.278 2022/04/16 19:18:17 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.279 2022/04/30 21:38:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.278 2022/04/16 19:18:17 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.279 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <sys/param.h>
@@ -328,7 +328,7 @@ add_type(type_t *tp)
dcs->d_rank_mod = NOTSPEC;
if (!quadflg)
/* %s does not support 'long long' */
- c99ism(265, tflag ? "traditional C" : "C90");
+ c99ism(265, allow_c90 ? "C90" : "traditional C");
}
if (dcs->d_type != NULL && dcs->d_type->t_typedef) {
@@ -410,7 +410,7 @@ tdeferr(type_t *td, tspec_t t)
if ((t == SIGNED || t == UNSIGN) &&
(t2 == CHAR || t2 == SHORT || t2 == INT ||
t2 == LONG || t2 == QUAD)) {
- if (!tflag)
+ if (allow_c90)
/* modifying typedef with '%s'; only qualifiers... */
warning(5, tspec_name(t));
td = block_dup_type(gettyp(merge_signedness(t2, t)));
@@ -766,7 +766,7 @@ dcs_merge_declaration_specifiers(void)
if (l == LONG && t == FLOAT) {
l = NOTSPEC;
t = DOUBLE;
- if (!tflag)
+ if (allow_c90)
/* use 'double' instead of 'long float' */
warning(6);
}
@@ -774,7 +774,7 @@ dcs_merge_declaration_specifiers(void)
l = NOTSPEC;
t = LDOUBLE;
}
- if (t == LDOUBLE && tflag) {
+ if (t == LDOUBLE && !allow_c90) {
/* 'long double' is illegal in traditional C */
warning(266);
}
@@ -974,7 +974,7 @@ check_type(sym_t *sym)
}
return;
} else if (tp->t_const || tp->t_volatile) {
- if (sflag) { /* XXX or better !tflag ? */
+ if (sflag) { /* XXX or better allow_c90? */
/* function cannot return const... */
warning(228);
}
@@ -1414,7 +1414,7 @@ add_function(sym_t *decl, sym_t *args)
#endif
if (dcs->d_proto) {
- if (tflag)
+ if (!allow_c90)
/* function prototypes are illegal in traditional C */
warning(270);
args = new_style_function(args);
@@ -1699,7 +1699,7 @@ mktag(sym_t *tag, tspec_t kind, bool dec
/* a new tag, no empty declaration */
dcs->d_enclosing->d_nonempty_decl = true;
if (scl == ENUM_TAG && !decl) {
- if (!tflag && (sflag || pflag))
+ if (allow_c90 && (sflag || pflag))
/* forward reference to enum type */
warning(42);
}
@@ -1752,7 +1752,7 @@ newtag(sym_t *tag, scl_t scl, bool decl,
if (tag->s_block_level < block_level) {
if (semi) {
/* "struct a;" */
- if (!tflag) {
+ if (allow_c90) {
if (!sflag)
/* declaration introduces new ... */
warning(44, storage_class_name(scl),
@@ -2181,10 +2181,10 @@ check_redeclaration(sym_t *dsym, bool *d
static bool
qualifiers_correspond(const type_t *tp1, const type_t *tp2, bool ignqual)
{
- if (tp1->t_const != tp2->t_const && !ignqual && !tflag)
+ if (tp1->t_const != tp2->t_const && !ignqual && allow_c90)
return false;
- if (tp1->t_volatile != tp2->t_volatile && !ignqual && !tflag)
+ if (tp1->t_volatile != tp2->t_volatile && !ignqual && allow_c90)
return false;
return true;
@@ -2227,12 +2227,12 @@ eqtype(const type_t *tp1, const type_t *
} else if (t == CHAR || t == SCHAR) {
t = INT;
} else if (t == UCHAR) {
- t = tflag ? UINT : INT;
+ t = allow_c90 ? INT : UINT;
} else if (t == SHORT) {
t = INT;
} else if (t == USHORT) {
/* CONSTCOND */
- t = TARG_INT_MAX < TARG_USHRT_MAX || tflag
+ t = TARG_INT_MAX < TARG_USHRT_MAX || !allow_c90
? UINT : INT;
}
}
@@ -2255,7 +2255,7 @@ eqtype(const type_t *tp1, const type_t *
}
/* don't check prototypes for traditional */
- if (t == FUNC && !tflag) {
+ if (t == FUNC && allow_c90) {
if (tp1->t_proto && tp2->t_proto) {
if (!eqargs(tp1, tp2, dowarn))
return false;
@@ -2468,12 +2468,12 @@ declare_argument(sym_t *sym, bool initfl
if ((t = sym->s_type->t_tspec) == ARRAY) {
sym->s_type = block_derive_type(sym->s_type->t_subt, PTR);
} else if (t == FUNC) {
- if (tflag)
+ if (!allow_c90)
/* a function is declared as an argument: %s */
warning(50, sym->s_name);
sym->s_type = block_derive_type(sym->s_type, PTR);
} else if (t == FLOAT) {
- if (tflag)
+ if (!allow_c90)
sym->s_type = gettyp(DOUBLE);
}
@@ -2704,10 +2704,10 @@ check_local_redeclaration(const sym_t *d
/* no hflag, because it's illegal! */
if (rsym->s_arg) {
/*
- * if !tflag, a "redeclaration of %s" error
+ * if allow_c90, a "redeclaration of %s" error
* is produced below
*/
- if (tflag) {
+ if (!allow_c90) {
if (hflag)
/* declaration hides parameter: %s */
warning(91, dsym->s_name);
@@ -2758,7 +2758,7 @@ declare_local(sym_t *dsym, bool 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
+ * XXX it should have an effect if !allow_c90 is set. this would
* also be the way gcc behaves.
*/
if (dcs->d_inline) {
@@ -2983,7 +2983,7 @@ check_size(sym_t *dsym)
if (length_in_bits(dsym->s_type, dsym->s_name) == 0 &&
dsym->s_type->t_tspec == ARRAY && dsym->s_type->t_dim == 0) {
- if (tflag) {
+ if (!allow_c90) {
/* empty array declaration: %s */
warning(190, dsym->s_name);
} else {
@@ -3261,7 +3261,7 @@ check_static_global_variable(const sym_t
if (!sym->s_used)
check_unused_static_global_variable(sym);
- if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) {
+ if (allow_c90 && sym->s_def == TDEF && sym->s_type->t_const) {
/* const object %s should have initializer */
warning_at(227, &sym->s_def_pos, sym->s_name);
}
@@ -3311,7 +3311,7 @@ check_global_variable_size(const sym_t *
if (len_in_bits == 0 &&
sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) {
- if (tflag || (sym->s_scl == EXTERN && !sflag)) {
+ if (!allow_c90 || (sym->s_scl == EXTERN && !sflag)) {
/* empty array declaration: %s */
warning_at(190, &sym->s_def_pos, sym->s_name);
} else {
Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.158 src/usr.bin/xlint/lint1/externs1.h:1.159
--- src/usr.bin/xlint/lint1/externs1.h:1.158 Sat Apr 30 20:24:57 2022
+++ src/usr.bin/xlint/lint1/externs1.h Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.158 2022/04/30 20:24:57 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.159 2022/04/30 21:38:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -60,13 +60,12 @@ extern bool allow_gcc;
* TODO: Replace the old flags with the new expressions, checking in each
* case whether the specific condition still makes sense. When lint was
* invented in 1995, it did not know about C99 mode, which makes all
- * conditions involving tflag and sflag suspicious.
+ * conditions involving sflag suspicious.
*
* In 1995, gflag meant "C90 plus GCC extensions". That definition needs to
* be extended to C99 and later as well to properly match "C99 + GCC" or "C11
* + GCC", in all calls to gnuism.
*/
-#define tflag (allow_trad && !allow_c90)
#define sflag (!allow_trad && !allow_c99)
extern void norecover(void);
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.133 src/usr.bin/xlint/lint1/func.c:1.134
--- src/usr.bin/xlint/lint1/func.c:1.133 Sat Apr 30 19:18:48 2022
+++ src/usr.bin/xlint/lint1/func.c Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.133 2022/04/30 19:18:48 rillig Exp $ */
+/* $NetBSD: func.c,v 1.134 2022/04/30 21:38:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.133 2022/04/30 19:18:48 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.134 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <stdlib.h>
@@ -521,7 +521,7 @@ check_case_label(tnode_t *tn, control_st
t = tn->tn_type->t_tspec;
if (t == LONG || t == ULONG ||
t == QUAD || t == UQUAD) {
- if (tflag)
+ if (!allow_c90)
/* case label must be of type 'int' in traditional C */
warning(203);
}
@@ -694,7 +694,7 @@ switch1(tnode_t *tn)
error(205);
tn = NULL;
}
- if (tn != NULL && tflag) {
+ if (tn != NULL && !allow_c90) {
t = tn->tn_type->t_tspec;
if (t == LONG || t == ULONG || t == QUAD || t == UQUAD) {
/* switch expression must be of type 'int' in ... */
Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.233 src/usr.bin/xlint/lint1/init.c:1.234
--- src/usr.bin/xlint/lint1/init.c:1.233 Sat Apr 2 22:38:45 2022
+++ src/usr.bin/xlint/lint1/init.c Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.233 2022/04/02 22:38:45 rillig Exp $ */
+/* $NetBSD: init.c,v 1.234 2022/04/30 21:38:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.233 2022/04/02 22:38:45 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.234 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <stdlib.h>
@@ -262,7 +262,7 @@ static void
check_bit_field_init(const tnode_t *ln, tspec_t lt, tspec_t rt)
{
- if (tflag &&
+ if (!allow_c90 &&
is_integer(lt) &&
ln->tn_type->t_bitfield &&
!is_integer(rt)) {
@@ -775,10 +775,10 @@ initialization_lbrace(initialization *in
goto done;
outer_bl = in->in_brace_level;
- if (tflag && outer_bl == NULL)
+ if (!allow_c90 && outer_bl == NULL)
check_trad_no_auto_aggregate(in->in_sym);
- if (tflag && tp->t_tspec == UNION) {
+ if (!allow_c90 && tp->t_tspec == UNION) {
/* initialization of union is illegal in traditional C */
warning(238);
}
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.126 src/usr.bin/xlint/lint1/lex.c:1.127
--- src/usr.bin/xlint/lint1/lex.c:1.126 Sat Apr 30 20:43:16 2022
+++ src/usr.bin/xlint/lint1/lex.c Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.126 2022/04/30 20:43:16 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.127 2022/04/30 21:38:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.126 2022/04/30 20:43:16 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.127 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <ctype.h>
@@ -590,7 +590,7 @@ lex_integer_constant(const char *yytext,
if (u_suffix > 1)
u_suffix = 1;
}
- if (tflag && u_suffix != 0) {
+ if (!allow_c90 && u_suffix != 0) {
/* suffix U is illegal in traditional C */
warning(97);
}
@@ -627,7 +627,7 @@ lex_integer_constant(const char *yytext,
}
}
if (typ == UINT || typ == ULONG) {
- if (tflag) {
+ if (!allow_c90) {
typ = LONG;
} else if (!sflag) {
/*
@@ -648,7 +648,7 @@ lex_integer_constant(const char *yytext,
}
break;
case LONG:
- if (uq > TARG_LONG_MAX && !tflag) {
+ if (uq > TARG_LONG_MAX && allow_c90) {
typ = ULONG;
if (!sflag)
ansiu = true;
@@ -665,7 +665,7 @@ lex_integer_constant(const char *yytext,
}
break;
case QUAD:
- if (uq > TARG_QUAD_MAX && !tflag) {
+ if (uq > TARG_QUAD_MAX && allow_c90) {
typ = UQUAD;
if (!sflag)
ansiu = true;
@@ -746,7 +746,7 @@ lex_floating_constant(const char *yytext
typ = DOUBLE;
}
- if (tflag && typ != DOUBLE) {
+ if (!allow_c90 && typ != DOUBLE) {
/* suffixes F and L are illegal in traditional C */
warning(98);
}
@@ -915,7 +915,7 @@ get_escaped_char(int delim)
return -1;
switch (c) {
case '\n':
- if (tflag) {
+ if (!allow_c90) {
/* newline in string or char constant */
error(254);
return -2;
@@ -930,21 +930,21 @@ get_escaped_char(int delim)
case '\\':
switch (c = inpc()) {
case '"':
- if (tflag && delim == '\'')
+ if (!allow_c90 && delim == '\'')
/* \" inside character constants undef... */
warning(262);
return '"';
case '\'':
return '\'';
case '?':
- if (tflag)
+ if (!allow_c90)
/* \? undefined in traditional C */
warning(263);
return '?';
case '\\':
return '\\';
case 'a':
- if (tflag)
+ if (!allow_c90)
/* \a undefined in traditional C */
warning(81);
return '\a';
@@ -959,7 +959,7 @@ get_escaped_char(int delim)
case 't':
return '\t';
case 'v':
- if (tflag)
+ if (!allow_c90)
/* \v undefined in traditional C */
warning(264);
return '\v';
@@ -983,7 +983,7 @@ get_escaped_char(int delim)
}
return v;
case 'x':
- if (tflag)
+ if (!allow_c90)
/* \x undefined in traditional C */
warning(82);
v = 0;
Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.60 src/usr.bin/xlint/lint1/main1.c:1.61
--- src/usr.bin/xlint/lint1/main1.c:1.60 Sat Apr 16 13:25:27 2022
+++ src/usr.bin/xlint/lint1/main1.c Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.60 2022/04/16 13:25:27 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.61 2022/04/30 21:38:03 rillig 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.60 2022/04/16 13:25:27 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.61 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <sys/types.h>
@@ -285,7 +285,7 @@ main(int argc, char *argv[])
initdecl();
initscan();
- if (allow_gcc && !tflag) {
+ if (allow_gcc && allow_c90) {
if ((yyin = gcc_builtins()) == NULL)
err(1, "cannot open builtins");
yyparse();
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.437 src/usr.bin/xlint/lint1/tree.c:1.438
--- src/usr.bin/xlint/lint1/tree.c:1.437 Sat Apr 30 19:18:48 2022
+++ src/usr.bin/xlint/lint1/tree.c Sat Apr 30 21:38:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.437 2022/04/30 19:18:48 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.438 2022/04/30 21:38:03 rillig 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.437 2022/04/30 19:18:48 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.438 2022/04/30 21:38:03 rillig Exp $");
#endif
#include <float.h>
@@ -256,7 +256,7 @@ build_name_call(sym_t *sym)
warning(215, sym->s_name);
}
- /* XXX if tflag is set, the symbol should be exported to level 0 */
+ /* XXX if !allow_c90, the symbol should be exported to level 0 */
sym->s_type = block_derive_type(sym->s_type, FUNC);
}
@@ -452,7 +452,7 @@ struct_or_union_member(tnode_t *tn, op_t
* to a struct/union, but the right operand is not member of it.
*/
if (str != NULL) {
- if (eq && tflag) {
+ if (eq && !allow_c90) {
/* illegal member use: %s */
warning(102, msym->s_name);
} else {
@@ -468,7 +468,7 @@ struct_or_union_member(tnode_t *tn, op_t
*/
if (eq) {
if (op == POINT) {
- if (tflag) {
+ if (!allow_c90) {
/* left operand of '.' must be struct ... */
warning(103, type_name(tn->tn_type));
} else {
@@ -476,7 +476,7 @@ struct_or_union_member(tnode_t *tn, op_t
error(103, type_name(tn->tn_type));
}
} else {
- if (tflag && tn->tn_type->t_tspec == PTR) {
+ if (!allow_c90 && tn->tn_type->t_tspec == PTR) {
/* left operand of '->' must be pointer ... */
warning(104, type_name(tn->tn_type));
} else {
@@ -485,7 +485,7 @@ struct_or_union_member(tnode_t *tn, op_t
}
}
} else {
- if (tflag) {
+ if (!allow_c90) {
/* non-unique member requires struct/union %s */
error(105, op == POINT ? "object" : "pointer");
} else {
@@ -581,7 +581,7 @@ build_binary(tnode_t *ln, op_t op, bool
}
/* Make sure both operands are of the same type */
- if (mp->m_balance_operands || (tflag && (op == SHL || op == SHR)))
+ if (mp->m_balance_operands || (!allow_c90 && (op == SHL || op == SHR)))
balance(op, &ln, &rn);
/*
@@ -790,8 +790,8 @@ typeok_point(const tnode_t *ln, const ty
{
if (lt == FUNC || lt == VOID || ltp->t_bitfield ||
((lt != STRUCT && lt != UNION) && !ln->tn_lvalue)) {
- /* Without tflag we got already an error */
- if (tflag)
+ /* With allow_c90 we already got an error */
+ if (!allow_c90)
/* unacceptable operand of '%s' */
error(111, op_name(POINT));
return false;
@@ -802,11 +802,17 @@ typeok_point(const tnode_t *ln, const ty
static bool
typeok_arrow(tspec_t lt)
{
- if (lt == PTR || (tflag && is_integer(lt)))
+ /*
+ * C1978 Appendix A 14.1 says: <quote>In fact, any lvalue is allowed
+ * before '.', and that lvalue is then assumed to have the form of
+ * the structure of which the name of the right is a member. [...]
+ * Such constructions are non-portable.</quote>
+ */
+ if (lt == PTR || (!allow_c90 && is_integer(lt)))
return true;
- /* Without tflag we got already an error */
- if (tflag)
+ /* With allow_c90 we already got an error */
+ if (!allow_c90)
/* unacceptable operand of '%s' */
error(111, op_name(ARROW));
return false;
@@ -826,7 +832,7 @@ typeok_incdec(op_t op, const tnode_t *tn
error(114, "", op_name(op));
return false;
} else if (tp->t_const) {
- if (!tflag)
+ if (allow_c90)
/* %soperand of '%s' must be modifiable lvalue */
warning(115, "", op_name(op));
}
@@ -1141,7 +1147,7 @@ typeok_assign(op_t op, const tnode_t *ln
return false;
} else if (ltp->t_const || ((lt == STRUCT || lt == UNION) &&
has_constant_member(ltp))) {
- if (!tflag)
+ if (allow_c90)
/* %soperand of '%s' must be modifiable lvalue */
warning(115, "left ", op_name(op));
}
@@ -1255,7 +1261,8 @@ typeok_op(op_t op, const mod_t *mp, int
case SHLASS:
goto assign;
case SHRASS:
- if (pflag && !is_uinteger(lt) && !(tflag && is_uinteger(rt))) {
+ if (pflag && !is_uinteger(lt) &&
+ !(!allow_c90 && is_uinteger(rt))) {
/* bitwise '%s' on signed value possibly nonportable */
warning(117, mp->m_name);
}
@@ -1516,7 +1523,7 @@ check_assign_void_pointer_compat(op_t op
return false;
/* compatible pointer types (qualifiers ignored) */
- if (!tflag &&
+ if (allow_c90 &&
((!lstp->t_const && rstp->t_const) ||
(!lstp->t_volatile && rstp->t_volatile))) {
/* left side has not all qualifiers of right */
@@ -1539,7 +1546,7 @@ check_assign_void_pointer_compat(op_t op
}
}
- if (!tflag)
+ if (allow_c90)
check_unconst_function(lstp, rn);
return true;
@@ -1896,7 +1903,7 @@ new_tnode(op_t op, bool sys, type_t *typ
* Performs the "integer promotions" (C99 6.3.1.1p2), which convert small
* integer types to either int or unsigned int.
*
- * If tflag is set or the operand is a function argument with no type
+ * If allow_c90 is unset or the operand is a function argument with no type
* information (no prototype or variable # of args), converts float to double.
*/
tnode_t *
@@ -1911,7 +1918,7 @@ promote(op_t op, bool farg, tnode_t *tn)
if (!is_arithmetic(t))
return tn;
- if (!tflag) {
+ if (allow_c90) {
/*
* C99 6.3.1.1p2 requires for types with lower rank than int
* that "If an int can represent all the values of the
@@ -1996,7 +2003,7 @@ balance(op_t op, tnode_t **lnp, tnode_t
if (!is_arithmetic(lt) || !is_arithmetic(rt))
return;
- if (!tflag) {
+ if (allow_c90) {
if (lt == rt) {
t = lt;
} else if (lt == LCOMPLEX || rt == LCOMPLEX) {
@@ -2803,7 +2810,7 @@ build_struct_access(op_t op, bool sys, t
if (op == POINT) {
ln = build_address(sys, ln, true);
} else if (ln->tn_type->t_tspec != PTR) {
- lint_assert(tflag);
+ lint_assert(!allow_c90);
lint_assert(is_integer(ln->tn_type->t_tspec));
ln = convert(NOOP, 0, expr_derive_type(gettyp(VOID), PTR), ln);
}
@@ -2901,7 +2908,7 @@ build_address(bool sys, tnode_t *tn, boo
tspec_t t;
if (!noign && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) {
- if (tflag)
+ if (!allow_c90)
/* '&' before array or function: ignored */
warning(127);
return tn;