Module Name: src Committed By: rillig Date: Wed Jun 30 14:42:13 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_215.c src/usr.bin/xlint/lint1: tree.c Log Message: lint: do not warn about use of implicitly declared GCC builtins To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_215.c cvs rdiff -u -r1.302 -r1.303 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/tests/usr.bin/xlint/lint1/msg_215.c diff -u src/tests/usr.bin/xlint/lint1/msg_215.c:1.8 src/tests/usr.bin/xlint/lint1/msg_215.c:1.9 --- src/tests/usr.bin/xlint/lint1/msg_215.c:1.8 Wed Jun 30 14:32:41 2021 +++ src/tests/usr.bin/xlint/lint1/msg_215.c Wed Jun 30 14:42:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_215.c,v 1.8 2021/06/30 14:32:41 rillig Exp $ */ +/* $NetBSD: msg_215.c,v 1.9 2021/06/30 14:42:13 rillig Exp $ */ # 3 "msg_215.c" // Test for message: function '%s' implicitly declared to return int [215] @@ -27,4 +27,8 @@ test(struct str str) /* expect+2: error: type 'struct str' does not have member 'member' [101] */ /* expect+1: error: illegal function (type int) [149] */ str.member(); + + /* https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html */ + __builtin_whatever(123, "string"); + __atomic_whatever(123, "string"); } Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.302 src/usr.bin/xlint/lint1/tree.c:1.303 --- src/usr.bin/xlint/lint1/tree.c:1.302 Wed Jun 30 14:32:41 2021 +++ src/usr.bin/xlint/lint1/tree.c Wed Jun 30 14:42:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.302 2021/06/30 14:32:41 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.303 2021/06/30 14:42:13 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.302 2021/06/30 14:32:41 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.303 2021/06/30 14:42:13 rillig Exp $"); #endif #include <float.h> @@ -232,6 +232,14 @@ fallback_symbol(sym_t *sym) error(99, sym->s_name); } +/* https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html */ +static bool +is_gcc_builtin(const char *name) +{ + return strncmp(name, "__atomic_", 9) == 0 || + strncmp(name, "__builtin_", 10) == 0; +} + /* * Create a node for a name (symbol table entry). * follow_token is the token which follows the name. @@ -245,7 +253,13 @@ new_name_node(sym_t *sym, int follow_tok sym->s_scl = EXTERN; sym->s_def = DECL; if (follow_token == T_LPAREN) { - if (Sflag) { + if (gflag && is_gcc_builtin(sym->s_name)) { + /* + * Do not warn about these, just assume that + * they are regular functions compatible with + * non-prototype calling conventions. + */ + } else if (Sflag) { /* function '%s' implicitly declared to ... */ warning(215, sym->s_name); } else if (sflag) {