summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-11-29 03:40:57 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-11-29 03:40:57 +0000
commitcfc56fc6306abf453873cafd56a0a18548e2071b (patch)
tree07fd2659fc14009c898f1231c7f5cfc3ee144eb6 /usr.bin
parentf94dbdd04e11da76f1a4c1fab15919c3b2a2807d (diff)
Make lint grok __func__, which in C99 is a predifined identifier that
holds the name of the current function. Makes thousands of lint warnings vanish and since lint can now fully parse compound expressions involving __func__, we see some new interesting warnings instead.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xlint/lint1/func.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c
index 86ecb782a5b..8379dca5f9b 100644
--- a/usr.bin/xlint/lint1/func.c
+++ b/usr.bin/xlint/lint1/func.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: func.c,v 1.6 2005/11/19 03:35:27 cloder Exp $ */
+/* $OpenBSD: func.c,v 1.7 2005/11/29 03:40:56 cloder Exp $ */
/* $NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $ */
/*
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: func.c,v 1.6 2005/11/19 03:35:27 cloder Exp $";
+static char rcsid[] = "$OpenBSD: func.c,v 1.7 2005/11/29 03:40:56 cloder Exp $";
#endif
#include <stdlib.h>
@@ -218,6 +218,26 @@ funcdef(sym_t *fsym)
}
/*
+ * __func__ is a "predefined identifier" in c99, which means it is a
+ * block-scope variable supplying the name of the enclosing function.
+ * It is defined as:
+ *
+ * static const char __func__[] = "function-name";
+ *
+ */
+ sym = getblk(sizeof (sym_t));
+ sym->s_name = "__func__";
+ sym->s_kind = FVFT;
+ sym->s_scl = STATIC;
+ sym->s_type = incref(gettyp(CHAR), ARRAY);
+ sym->s_blklev = 1;
+ sym->s_def = DEF;
+ sym->s_type->t_dim = strlen(fsym->s_name) + 1;
+ sym->s_type->t_subt = duptyp(gettyp(CHAR));
+ sym->s_type->t_subt->t_const = 1;
+ inssym(1, sym);
+
+ /*
* In osfunc() we did not know whether it is an old style function
* definition or only an old style declaration, if there are no
* arguments inside the argument list ("f()").