Module Name: src
Committed By: rillig
Date: Mon Nov 1 19:48:51 UTC 2021
Modified Files:
src/usr.bin/xlint: Makefile.inc
src/usr.bin/xlint/common: lint.h
src/usr.bin/xlint/lint1: ckgetopt.c lint1.h tree.c
src/usr.bin/xlint/lint2: lint2.h
Log Message:
lint: enter full C90 compatibility mode
The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.
Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/Makefile.inc
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/lint.h
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/ckgetopt.c
cvs rdiff -u -r1.129 -r1.130 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.392 -r1.393 src/usr.bin/xlint/lint1/tree.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/lint2/lint2.h
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/Makefile.inc
diff -u src/usr.bin/xlint/Makefile.inc:1.16 src/usr.bin/xlint/Makefile.inc:1.17
--- src/usr.bin/xlint/Makefile.inc:1.16 Mon Nov 1 19:10:07 2021
+++ src/usr.bin/xlint/Makefile.inc Mon Nov 1 19:48:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.16 2021/11/01 19:10:07 rillig Exp $
+# $NetBSD: Makefile.inc,v 1.17 2021/11/01 19:48:51 rillig Exp $
.include <bsd.own.mk>
@@ -16,7 +16,8 @@ ARCHSUBDIR= ${MACHINE_CPU}
CPPFLAGS+= -I${.CURDIR}/../arch/${ARCHSUBDIR}
CPPFLAGS+= -I${.CURDIR}/../common
-CWARNFLAGS+= -Wdeclaration-after-statement # it's a build tool
+CWARNFLAGS.gcc+=-Wdeclaration-after-statement # see tools/README
+CWARNFLAGS.gcc+=-std=c90 # see tools/README
CLEANFILES+= *.gcno *.gcda *.gcov
Index: src/usr.bin/xlint/common/lint.h
diff -u src/usr.bin/xlint/common/lint.h:1.32 src/usr.bin/xlint/common/lint.h:1.33
--- src/usr.bin/xlint/common/lint.h:1.32 Sun Sep 5 18:17:15 2021
+++ src/usr.bin/xlint/common/lint.h Mon Nov 1 19:48:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint.h,v 1.32 2021/09/05 18:17:15 rillig Exp $ */
+/* $NetBSD: lint.h,v 1.33 2021/11/01 19:48:51 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -149,13 +149,21 @@ typedef struct lint2_type type_t;
#include "externs.h"
-static inline bool
+#if __STDC_VERSION__ >= 199901L
+#define INLINE_FUNC static inline
+#elif __GNUC__
+#define INLINE_FUNC static __attribute__((__unused__))
+#else
+#define INLINE_FUNC static
+#endif
+
+INLINE_FUNC bool
ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; }
-static inline bool
+INLINE_FUNC bool
ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; }
-static inline bool
+INLINE_FUNC bool
ch_isprint(char ch) { return isprint((unsigned char)ch) != 0; }
-static inline bool
+INLINE_FUNC bool
ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; }
-static inline bool
+INLINE_FUNC bool
ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; }
Index: src/usr.bin/xlint/lint1/ckgetopt.c
diff -u src/usr.bin/xlint/lint1/ckgetopt.c:1.13 src/usr.bin/xlint/lint1/ckgetopt.c:1.14
--- src/usr.bin/xlint/lint1/ckgetopt.c:1.13 Mon Nov 1 19:10:07 2021
+++ src/usr.bin/xlint/lint1/ckgetopt.c Mon Nov 1 19:48:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ckgetopt.c,v 1.13 2021/11/01 19:10:07 rillig Exp $ */
+/* $NetBSD: ckgetopt.c,v 1.14 2021/11/01 19:48:51 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckgetopt.c,v 1.13 2021/11/01 19:10:07 rillig Exp $");
+__RCSID("$NetBSD: ckgetopt.c,v 1.14 2021/11/01 19:48:51 rillig Exp $");
#endif
#include <stdbool.h>
@@ -133,9 +133,11 @@ check_unlisted_option(char opt)
static void
check_unhandled_option(void)
{
+ const char *opt;
+
lint_assert(ck.options != NULL);
- for (const char *opt = ck.options; *opt != '\0'; opt++) {
+ for (opt = ck.options; *opt != '\0'; opt++) {
if (*opt == ' ' || *opt == ':')
continue;
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.129 src/usr.bin/xlint/lint1/lint1.h:1.130
--- src/usr.bin/xlint/lint1/lint1.h:1.129 Tue Sep 14 19:44:40 2021
+++ src/usr.bin/xlint/lint1/lint1.h Mon Nov 1 19:48:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.129 2021/09/14 19:44:40 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.130 2021/11/01 19:48:51 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -497,7 +497,7 @@ extern err_set msgset;
# include "err-msgs.h"
/* ARGSUSED */
-static inline void __attribute__((format(printf, 1, 2)))
+INLINE_FUNC void __attribute__((format(printf, 1, 2)))
check_printf(const char *fmt, ...)
{
}
@@ -528,7 +528,7 @@ check_printf(const char *fmt, ...)
# define c11ism(msgid, args...) wrap_check_printf(c11ism, msgid, ##args)
#endif
-static inline bool
+INLINE_FUNC bool
is_nonzero_val(const val_t *val)
{
return is_floating(val->v_tspec)
@@ -536,7 +536,7 @@ is_nonzero_val(const val_t *val)
: val->v_quad != 0;
}
-static inline bool
+INLINE_FUNC bool
constant_is_nonzero(const tnode_t *tn)
{
lint_assert(tn->tn_op == CON);
@@ -544,25 +544,25 @@ constant_is_nonzero(const tnode_t *tn)
return is_nonzero_val(tn->tn_val);
}
-static inline bool
+INLINE_FUNC bool
is_zero(const tnode_t *tn)
{
return tn != NULL && tn->tn_op == CON && !is_nonzero_val(tn->tn_val);
}
-static inline bool
+INLINE_FUNC bool
is_nonzero(const tnode_t *tn)
{
return tn != NULL && tn->tn_op == CON && is_nonzero_val(tn->tn_val);
}
-static inline bool
+INLINE_FUNC bool
is_binary(const tnode_t *tn)
{
return modtab[tn->tn_op].m_binary;
}
-static inline uint64_t
+INLINE_FUNC uint64_t
bit(unsigned i)
{
/*
@@ -576,13 +576,13 @@ bit(unsigned i)
return (uint64_t)1 << i;
}
-static inline bool
+INLINE_FUNC bool
msb(int64_t q, tspec_t t)
{
return (q & bit((unsigned int)size_in_bits(t) - 1)) != 0;
}
-static inline uint64_t
+INLINE_FUNC uint64_t
value_bits(unsigned bitsize)
{
lint_assert(bitsize > 0);
@@ -600,7 +600,7 @@ value_bits(unsigned bitsize)
}
/* C99 6.7.8p7 */
-static inline bool
+INLINE_FUNC bool
is_struct_or_union(tspec_t t)
{
return t == STRUCT || t == UNION;
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.392 src/usr.bin/xlint/lint1/tree.c:1.393
--- src/usr.bin/xlint/lint1/tree.c:1.392 Mon Nov 1 19:10:07 2021
+++ src/usr.bin/xlint/lint1/tree.c Mon Nov 1 19:48:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.392 2021/11/01 19:10:07 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.393 2021/11/01 19:48:51 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.392 2021/11/01 19:10:07 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.393 2021/11/01 19:48:51 rillig Exp $");
#endif
#include <float.h>
@@ -3465,7 +3465,7 @@ build_offsetof(const type_t *tp, const s
/* unacceptable operand of '%s' */
error(111, "offsetof");
- // XXX: wrong size, no checking for sym fixme
+ /* XXX: wrong size, no checking for sym fixme */
offset_in_bytes = type_size_in_bits(tp) / CHAR_SIZE;
tn = build_integer_constant(SIZEOF_TSPEC, offset_in_bytes);
tn->tn_system_dependent = true;
@@ -3935,7 +3935,7 @@ expr(tnode_t *tn, bool vctx, bool tctx,
}
static bool
-has_side_effect(const tnode_t *tn) // NOLINT(misc-no-recursion)
+has_side_effect(const tnode_t *tn) /* NOLINT(misc-no-recursion) */
{
op_t op = tn->tn_op;
Index: src/usr.bin/xlint/lint2/lint2.h
diff -u src/usr.bin/xlint/lint2/lint2.h:1.19 src/usr.bin/xlint/lint2/lint2.h:1.20
--- src/usr.bin/xlint/lint2/lint2.h:1.19 Sun Aug 29 10:13:02 2021
+++ src/usr.bin/xlint/lint2/lint2.h Mon Nov 1 19:48:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint2.h,v 1.19 2021/08/29 10:13:02 rillig Exp $ */
+/* $NetBSD: lint2.h,v 1.20 2021/11/01 19:48:51 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -186,7 +186,7 @@ typedef struct hte {
#include "externs2.h"
/* maps type indices into pointers to type structs */
-static inline type_t *
+INLINE_FUNC type_t *
TP(unsigned short type_id) {
/* force sequence point for newly parsed type_id */
return tlst[type_id];