Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint lint: enter full C90 compatibility mode



details:   https://anonhg.NetBSD.org/src/rev/536c3c752d62
branches:  trunk
changeset: 990668:536c3c752d62
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 01 19:48:51 2021 +0000

description:
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.

diffstat:

 usr.bin/xlint/Makefile.inc     |   5 +++--
 usr.bin/xlint/common/lint.h    |  20 ++++++++++++++------
 usr.bin/xlint/lint1/ckgetopt.c |   8 +++++---
 usr.bin/xlint/lint1/lint1.h    |  22 +++++++++++-----------
 usr.bin/xlint/lint1/tree.c     |   8 ++++----
 usr.bin/xlint/lint2/lint2.h    |   4 ++--
 6 files changed, 39 insertions(+), 28 deletions(-)

diffs (231 lines):

diff -r 4b3a435063f9 -r 536c3c752d62 usr.bin/xlint/Makefile.inc
--- a/usr.bin/xlint/Makefile.inc        Mon Nov 01 19:37:32 2021 +0000
+++ b/usr.bin/xlint/Makefile.inc        Mon Nov 01 19:48:51 2021 +0000
@@ -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 @@
 
 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
 
diff -r 4b3a435063f9 -r 536c3c752d62 usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Mon Nov 01 19:37:32 2021 +0000
+++ b/usr.bin/xlint/common/lint.h       Mon Nov 01 19:48:51 2021 +0000
@@ -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 @@
 
 #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; }
diff -r 4b3a435063f9 -r 536c3c752d62 usr.bin/xlint/lint1/ckgetopt.c
--- a/usr.bin/xlint/lint1/ckgetopt.c    Mon Nov 01 19:37:32 2021 +0000
+++ b/usr.bin/xlint/lint1/ckgetopt.c    Mon Nov 01 19:48:51 2021 +0000
@@ -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 @@
 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;
 
diff -r 4b3a435063f9 -r 536c3c752d62 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Mon Nov 01 19:37:32 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Mon Nov 01 19:48:51 2021 +0000
@@ -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 @@
 #  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 @@
 #  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 @@
            : 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 @@
        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 @@
        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 @@
 }
 
 /* C99 6.7.8p7 */
-static inline bool
+INLINE_FUNC bool
 is_struct_or_union(tspec_t t)
 {
        return t == STRUCT || t == UNION;
diff -r 4b3a435063f9 -r 536c3c752d62 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Nov 01 19:37:32 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Nov 01 19:48:51 2021 +0000
@@ -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 @@
                /* 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 @@
 }
 
 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;
 
diff -r 4b3a435063f9 -r 536c3c752d62 usr.bin/xlint/lint2/lint2.h
--- a/usr.bin/xlint/lint2/lint2.h       Mon Nov 01 19:37:32 2021 +0000
+++ b/usr.bin/xlint/lint2/lint2.h       Mon Nov 01 19:48:51 2021 +0000
@@ -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 @@
 #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];



Home | Main Index | Thread Index | Old Index