Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: demonstrate wrong declaration of _...



details:   https://anonhg.NetBSD.org/src/rev/065d80dba7d4
branches:  trunk
changeset: 373286:065d80dba7d4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 29 17:36:26 2023 +0000

description:
lint: demonstrate wrong declaration of __func__

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_func.c |  14 +++++++++-----
 usr.bin/xlint/lint1/tree.c             |   5 +++--
 2 files changed, 12 insertions(+), 7 deletions(-)

diffs (50 lines):

diff -r 50eaeba0be60 -r 065d80dba7d4 tests/usr.bin/xlint/lint1/d_c99_func.c
--- a/tests/usr.bin/xlint/lint1/d_c99_func.c    Sun Jan 29 17:20:48 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_func.c    Sun Jan 29 17:36:26 2023 +0000
@@ -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__;
 }
diff -r 50eaeba0be60 -r 065d80dba7d4 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jan 29 17:20:48 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jan 29 17:36:26 2023 +0000
@@ -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 @@
                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;



Home | Main Index | Thread Index | Old Index