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: add __sync_ and _mm_ as prefixes f...
details: https://anonhg.NetBSD.org/src/rev/efb0d00031e8
branches: trunk
changeset: 1023207:efb0d00031e8
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 29 15:49:04 2021 +0000
description:
lint: add __sync_ and _mm_ as prefixes for builtin functions
These two additions cover all cases that occur in the current NetBSD
build on x86_64. This allows build_name to use the usual pattern 'if
Sflag then error else if sflag then warning'. That function currently
issues a warning in C99 as well, even though C99 prohibits implicit
function declarations.
diffstat:
tests/usr.bin/xlint/lint1/msg_215.c | 9 +++++++--
usr.bin/xlint/lint1/decl.c | 6 +++---
usr.bin/xlint/lint1/externs1.h | 4 ++--
usr.bin/xlint/lint1/tree.c | 36 ++++++++++++++++++++++++------------
4 files changed, 36 insertions(+), 19 deletions(-)
diffs (147 lines):
diff -r d791b6cd676a -r efb0d00031e8 tests/usr.bin/xlint/lint1/msg_215.c
--- a/tests/usr.bin/xlint/lint1/msg_215.c Sun Aug 29 11:43:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_215.c Sun Aug 29 15:49:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_215.c,v 1.9 2021/06/30 14:42:13 rillig Exp $ */
+/* $NetBSD: msg_215.c,v 1.10 2021/08/29 15:49:04 rillig Exp $ */
# 3 "msg_215.c"
// Test for message: function '%s' implicitly declared to return int [215]
@@ -15,7 +15,7 @@
/* ARGSUSED */
void
-test(struct str str)
+test(struct str str, const double *p_double)
{
/* expect+1: warning: function 'name' implicitly declared to return int [215] */
name();
@@ -31,4 +31,9 @@
/* https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html */
__builtin_whatever(123, "string");
__atomic_whatever(123, "string");
+ /* obsolete but still in use, as of 2021 */
+ __sync_whatever(123, "string");
+
+ /* https://software.intel.com/sites/landingpage/IntrinsicsGuide/ */
+ _mm_load_sd(p_double);
}
diff -r d791b6cd676a -r efb0d00031e8 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun Aug 29 11:43:48 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun Aug 29 15:49:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.227 2021/08/28 16:36:54 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.228 2021/08/29 15:49:04 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.227 2021/08/28 16:36:54 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.228 2021/08/29 15:49:04 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 if (!is_gcc_builtin(dsym->s_name)) {
+ } else if (!is_compiler_builtin(dsym->s_name)) {
outsym(dsym, dsym->s_scl, dsym->s_def);
}
diff -r d791b6cd676a -r efb0d00031e8 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sun Aug 29 11:43:48 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sun Aug 29 15:49:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.136 2021/08/28 16:36:54 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.137 2021/08/29 15:49:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -234,7 +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 bool is_compiler_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 d791b6cd676a -r efb0d00031e8 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Aug 29 11:43:48 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Aug 29 15:49:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.360 2021/08/28 16:51:57 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.361 2021/08/29 15:49:04 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.360 2021/08/28 16:51:57 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.361 2021/08/29 15:49:04 rillig Exp $");
#endif
#include <float.h>
@@ -192,17 +192,28 @@
}
/*
- * 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
+ * Functions that are predeclared by GCC or other compilers can be called
+ * with arbitrary arguments. Since lint usually runs after a successful
+ * compilation, it's the compiler's job to catch any errors.
*/
bool
-is_gcc_builtin(const char *name)
+is_compiler_builtin(const char *name)
{
- return strncmp(name, "__atomic_", 9) == 0 ||
- strncmp(name, "__builtin_", 10) == 0;
+ /* https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html */
+ if (strncmp(name, "__atomic_", 9) == 0 ||
+ strncmp(name, "__builtin_", 10) == 0)
+ return true;
+
+ /* https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html */
+ /* obsolete but still in use, as of 2021 */
+ if (strncmp(name, "__sync_", 7) == 0)
+ return true;
+
+ /* https://software.intel.com/sites/landingpage/IntrinsicsGuide/ */
+ if (strncmp(name, "_mm_", 4) == 0)
+ return true;
+
+ return false;
}
/*
@@ -218,7 +229,7 @@
sym->s_scl = EXTERN;
sym->s_def = DECL;
if (follow_token == T_LPAREN) {
- if (gflag && is_gcc_builtin(sym->s_name)) {
+ if (gflag && is_compiler_builtin(sym->s_name)) {
/*
* Do not warn about these, just assume that
* they are regular functions compatible with
@@ -3945,7 +3956,8 @@
case CALL:
lint_assert(ln->tn_op == ADDR);
lint_assert(ln->tn_left->tn_op == NAME);
- if (!szof && !is_gcc_builtin(ln->tn_left->tn_sym->s_name))
+ if (!szof &&
+ !is_compiler_builtin(ln->tn_left->tn_sym->s_name))
outcall(tn, vctx || tctx, rvdisc);
break;
case EQ:
Home |
Main Index |
Thread Index |
Old Index