Module Name: src
Committed By: rillig
Date: Fri Sep 3 22:27:32 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: tree.c
Log Message:
lint: extract build_name_call from build_name
This reduces the indentation, providing enough space to write out the
full diagnostic in the code. It also prepares for supporting GCC
builtins like __builtin_add_overflow, which return _Bool instead of int.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 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/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.370 src/usr.bin/xlint/lint1/tree.c:1.371
--- src/usr.bin/xlint/lint1/tree.c:1.370 Thu Sep 2 20:10:17 2021
+++ src/usr.bin/xlint/lint1/tree.c Fri Sep 3 22:27:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.370 2021/09/02 20:10:17 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.371 2021/09/03 22:27:32 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.370 2021/09/02 20:10:17 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.371 2021/09/03 22:27:32 rillig Exp $");
#endif
#include <float.h>
@@ -215,6 +215,28 @@ is_compiler_builtin(const char *name)
return false;
}
+static void
+build_name_call(sym_t *sym)
+{
+
+ if (is_compiler_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 return int */
+ error(215, sym->s_name);
+ } else if (sflag) {
+ /* function '%s' implicitly declared to return int */
+ warning(215, sym->s_name);
+ }
+
+ /* XXX if tflag is set, the symbol should be exported to level 0 */
+ sym->s_type = derive_type(sym->s_type, FUNC);
+}
+
/*
* Create a node for a name (symbol table entry).
* follow_token is the token which follows the name.
@@ -228,24 +250,7 @@ build_name(sym_t *sym, int follow_token)
sym->s_scl = EXTERN;
sym->s_def = DECL;
if (follow_token == T_LPAREN) {
- if (is_compiler_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 ... */
- error(215, sym->s_name);
- } else if (sflag) {
- /* function '%s' implicitly declared to ... */
- warning(215, sym->s_name);
- }
- /*
- * XXX if tflag is set the symbol should be
- * exported to level 0
- */
- sym->s_type = derive_type(sym->s_type, FUNC);
+ build_name_call(sym);
} else {
fallback_symbol(sym);
}