Module Name: src Committed By: rillig Date: Fri Dec 17 00:05:24 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: main1.c tree.c Log Message: lint: in GCC mode, declare alloca and variants The prototype declarations define the correct parameter types of these functions so that they are no longer subject to the default argument promotions (C11 6.5.2.2p6). The GCC builtins are only recognized in GCC mode (-g). To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.399 -r1.400 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/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.57 src/usr.bin/xlint/lint1/main1.c:1.58 --- src/usr.bin/xlint/lint1/main1.c:1.57 Sat Aug 28 13:29:26 2021 +++ src/usr.bin/xlint/lint1/main1.c Fri Dec 17 00:05:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.57 2021/08/28 13:29:26 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.58 2021/12/17 00:05:24 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.57 2021/08/28 13:29:26 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.58 2021/12/17 00:05:24 rillig Exp $"); #endif #include <sys/types.h> @@ -133,7 +133,17 @@ static void usage(void); static FILE * gcc_builtins(void) { + /* https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */ static const char builtins[] = + "typedef typeof(sizeof(0)) __lint_size_t;\n" + + "void *alloca(__lint_size_t);\n" + "void *__builtin_alloca(__lint_size_t);\n" + "void *__builtin_alloca_with_align" + "(__lint_size_t, __lint_size_t);\n" + "void *__builtin_alloca_with_align_and_max" + "(__lint_size_t, __lint_size_t, __lint_size_t);\n" + "int __builtin_isinf(long double);\n" "int __builtin_isnan(long double);\n" "int __builtin_copysign(long double, long double);\n"; Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.399 src/usr.bin/xlint/lint1/tree.c:1.400 --- src/usr.bin/xlint/lint1/tree.c:1.399 Thu Dec 16 23:46:21 2021 +++ src/usr.bin/xlint/lint1/tree.c Fri Dec 17 00:05:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.399 2021/12/16 23:46:21 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.400 2021/12/17 00:05:24 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.399 2021/12/16 23:46:21 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.400 2021/12/17 00:05:24 rillig Exp $"); #endif #include <float.h> @@ -203,6 +203,7 @@ is_compiler_builtin(const char *name) if (gflag) { if (strncmp(name, "__atomic_", 9) == 0 || strncmp(name, "__builtin_", 10) == 0 || + strcmp(name, "alloca") == 0 || /* obsolete but still in use, as of 2021 */ strncmp(name, "__sync_", 7) == 0) return true; @@ -234,14 +235,6 @@ is_gcc_bool_builtin(const char *name) str_endswith(name, "_overflow_p")); } -/* https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */ -static bool -is_gcc_void_pointer_builtin(const char *name) -{ - return strcmp(name, "__builtin_alloca") == 0 || - strncmp(name, "__builtin_alloca_", 17) == 0; -} - static void build_name_call(sym_t *sym) { @@ -252,11 +245,8 @@ build_name_call(sym_t *sym) * they are regular functions compatible with * non-prototype calling conventions. */ - - if (is_gcc_bool_builtin(sym->s_name)) + if (gflag && is_gcc_bool_builtin(sym->s_name)) sym->s_type = gettyp(BOOL); - else if (is_gcc_void_pointer_builtin(sym->s_name)) - sym->s_type = derive_type(gettyp(VOID), PTR); } else if (Sflag) { /* function '%s' implicitly declared to return int */