Module Name: src
Committed By: rillig
Date: Sat Jun 8 11:55:41 UTC 2024
Modified Files:
src/tests/usr.bin/xlint/lint1: gcc.c
src/usr.bin/xlint/lint1: tree.c
Log Message:
lint: fix type of GCC-specific __FUNCTION__ to be an array
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/gcc.c
cvs rdiff -u -r1.644 -r1.645 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/gcc.c
diff -u src/tests/usr.bin/xlint/lint1/gcc.c:1.1 src/tests/usr.bin/xlint/lint1/gcc.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc.c:1.1 Sat Jun 8 09:09:20 2024
+++ src/tests/usr.bin/xlint/lint1/gcc.c Sat Jun 8 11:55:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc.c,v 1.1 2024/06/08 09:09:20 rillig Exp $ */
+/* $NetBSD: gcc.c,v 1.2 2024/06/08 11:55:40 rillig Exp $ */
# 3 "gcc.c"
/*
@@ -12,8 +12,8 @@
const char *
gcc_function(void)
{
- // TODO: make __FUNCTION__ an array, then uncomment the code.
- //typedef int size[-(int)sizeof __FUNCTION__];
+ /* expect+1: error: negative array dimension (-13) [20] */
+ typedef int size[-(int)sizeof __FUNCTION__];
return __FUNCTION__;
}
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.644 src/usr.bin/xlint/lint1/tree.c:1.645
--- src/usr.bin/xlint/lint1/tree.c:1.644 Sat Jun 8 06:37:06 2024
+++ src/usr.bin/xlint/lint1/tree.c Sat Jun 8 11:55:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.644 2024/06/08 06:37:06 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.645 2024/06/08 11:55:40 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.644 2024/06/08 06:37:06 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.645 2024/06/08 11:55:40 rillig Exp $");
#endif
#include <float.h>
@@ -403,14 +403,11 @@ fallback_symbol(sym_t *sym)
if (Tflag && fallback_symbol_strict_bool(sym))
return;
- if (block_level > 0 && (strcmp(sym->s_name, "__FUNCTION__") == 0 ||
+ if (funcsym != NULL && (strcmp(sym->s_name, "__FUNCTION__") == 0 ||
strcmp(sym->s_name, "__PRETTY_FUNCTION__") == 0)) {
/* __FUNCTION__/__PRETTY_FUNCTION__ is a GCC extension */
gnuism(316);
- // XXX: Should probably be ARRAY instead of PTR.
- sym->s_type = block_derive_type(gettyp(CHAR), PTR);
- sym->s_type->t_const = true;
- return;
+ goto return_function_name;
}
if (funcsym != NULL && strcmp(sym->s_name, "__func__") == 0) {
@@ -418,6 +415,7 @@ fallback_symbol(sym_t *sym)
/* __func__ is a C99 feature */
warning(317);
/* C11 6.4.2.2 */
+ return_function_name:
sym->s_type = block_derive_type(gettyp(CHAR), ARRAY);
sym->s_type->t_const = true;
sym->s_type->u.dimension = (int)strlen(funcsym->s_name) + 1;