Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: do not emit GCC builtin functions
details: https://anonhg.NetBSD.org/src/rev/476a742a3d6e
branches: trunk
changeset: 1023174:476a742a3d6e
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 28 16:36:54 2021 +0000
description:
lint: do not emit GCC builtin functions
Lint1 no longer emits declarations of GCC builtin functions and calls to
them.
Previously, lint generated 3421 useless warnings in a default NetBSD
build, like this:
__atomic_load_n, arg 1 used inconsistently
acl.c(216)[pointer to unsigned int]
rbtdb.c(921)[pointer to unsigned short]
This was because lint just doesn't understand that these functions are
type-generic, which is indeed unusual in C.
These useless warnings made the lint output more frightening than it
should actually be. Together with the strange formatting of the
diagnostics (space-space-tab after the main message, two spaces and two
colons between the occurrences, symbols are listed in hashcode order),
this creates the impression that lint is not intended to be a
user-friendly tool.
For now, fix the excess warnings, leaving the other items for later.
diffstat:
tests/usr.bin/xlint/lint1/emit.exp-ln | 6 ------
usr.bin/xlint/lint1/decl.c | 6 +++---
usr.bin/xlint/lint1/externs1.h | 3 ++-
usr.bin/xlint/lint1/tree.c | 16 +++++++++++-----
4 files changed, 16 insertions(+), 15 deletions(-)
diffs (106 lines):
diff -r e631ca09647e -r 476a742a3d6e tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln Sat Aug 28 16:21:24 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln Sat Aug 28 16:36:54 2021 +0000
@@ -1,6 +1,3 @@
-1d-1.1e15__builtin_isinfF1lDI
-2d-1.2e15__builtin_isnanF1lDI
-3d-1.3e18__builtin_copysignF2lDlDI
0semit.c
Semit.c
47d0.47e12extern__BoolB
@@ -59,7 +56,4 @@
163c0.163s2"%%"i9my_printff2PcCPCV
164c0.164s2"%\a%\b%\f%\n%\r%\t%\v%\177"i9my_printff2PcCPCV
159d0.159d14cover_outqcharF0V
-177c0.177p2i16__builtin_expectf2III
-178c0.178p1i17__builtin_bswap32f1II
-180c0.180z3i13__atomic_loadf3PLPLII
173d0.173d17call_gcc_builtinsF2IPLV
diff -r e631ca09647e -r 476a742a3d6e usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Aug 28 16:21:24 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Aug 28 16:36:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.226 2021/08/28 12:59:25 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.227 2021/08/28 16:36:54 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.226 2021/08/28 12:59:25 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.227 2021/08/28 16:36:54 rillig Exp $");
#endif
#include <sys/param.h>
@@ -1972,7 +1972,7 @@
*/
rval = dsym->s_type->t_subt->t_tspec != VOID;
outfdef(dsym, &dsym->s_def_pos, rval, false, NULL);
- } else {
+ } else if (!is_gcc_builtin(dsym->s_name)) {
outsym(dsym, dsym->s_scl, dsym->s_def);
}
diff -r e631ca09647e -r 476a742a3d6e usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sat Aug 28 16:21:24 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sat Aug 28 16:36:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.135 2021/08/28 13:11:10 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.136 2021/08/28 16:36:54 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -234,6 +234,7 @@
extern const tnode_t *before_conversion(const tnode_t *);
extern type_t *derive_type(type_t *, tspec_t);
extern type_t *expr_derive_type(type_t *, tspec_t);
+extern bool is_gcc_builtin(const char *);
extern tnode_t *build_constant(type_t *, val_t *);
extern tnode_t *build_name(sym_t *, int);
extern tnode_t *build_string(strg_t *);
diff -r e631ca09647e -r 476a742a3d6e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Aug 28 16:21:24 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Aug 28 16:36:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.357 2021/08/28 15:36:54 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.358 2021/08/28 16:36:54 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.357 2021/08/28 15:36:54 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.358 2021/08/28 16:36:54 rillig Exp $");
#endif
#include <float.h>
@@ -191,8 +191,14 @@
error(99, sym->s_name);
}
-/* https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html */
-static bool
+/*
+ * Functions that are predeclared by GCC can be called with arbitrary
+ * arguments. Since lint usually runs after a successful compilation, it's
+ * the compiler's job to catch any errors.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
+ */
+bool
is_gcc_builtin(const char *name)
{
return strncmp(name, "__atomic_", 9) == 0 ||
@@ -3939,7 +3945,7 @@
case CALL:
lint_assert(ln->tn_op == ADDR);
lint_assert(ln->tn_left->tn_op == NAME);
- if (!szof)
+ if (!szof && !is_gcc_builtin(ln->tn_left->tn_sym->s_name))
outcall(tn, vctx || tctx, rvdisc);
break;
case EQ:
Home |
Main Index |
Thread Index |
Old Index