Module Name: src
Committed By: rillig
Date: Sun Jan 29 17:36:26 UTC 2023
Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_func.c
src/usr.bin/xlint/lint1: tree.c
Log Message:
lint: demonstrate wrong declaration of __func__
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_func.c
cvs rdiff -u -r1.502 -r1.503 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/d_c99_func.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_func.c:1.3 src/tests/usr.bin/xlint/lint1/d_c99_func.c:1.4
--- src/tests/usr.bin/xlint/lint1/d_c99_func.c:1.3 Sun Jan 31 14:57:28 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_func.c Sun Jan 29 17:36:26 2023
@@ -1,11 +1,15 @@
-/* $NetBSD: d_c99_func.c,v 1.3 2021/01/31 14:57:28 rillig Exp $ */
+/* $NetBSD: d_c99_func.c,v 1.4 2023/01/29 17:36:26 rillig Exp $ */
# 3 "d_c99_func.c"
/* C99 __func__ */
-void
-foo(const char *p)
+const char *str;
+
+const char *
+function_name(void)
{
- p = __func__;
- foo(p);
+ /* FIXME: -14 for the array, not -8 for a pointer. */
+ /* expect+1: error: negative array dimension (-8) [20] */
+ typedef int reveal_size[-(int)sizeof(__func__)];
+ return __func__;
}
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.502 src/usr.bin/xlint/lint1/tree.c:1.503
--- src/usr.bin/xlint/lint1/tree.c:1.502 Sun Jan 29 17:13:10 2023
+++ src/usr.bin/xlint/lint1/tree.c Sun Jan 29 17:36:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.502 2023/01/29 17:13:10 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.503 2023/01/29 17:36:26 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.502 2023/01/29 17:13:10 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.503 2023/01/29 17:36:26 rillig Exp $");
#endif
#include <float.h>
@@ -404,6 +404,7 @@ fallback_symbol(sym_t *sym)
if (!allow_c99)
/* __func__ is a C99 feature */
warning(317);
+ /* C11 6.4.2.2 */
sym->s_type = block_derive_type(gettyp(CHAR), PTR);
sym->s_type->t_const = true;
return;