summaryrefslogtreecommitdiff
path: root/usr.bin/xlint/lint1/func.c
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-12-17 21:08:28 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-12-17 21:08:28 +0000
commit832a24ed5ab2dd786f06b3a0d48e761d8b471832 (patch)
treeb1f1b056d00d93ac27333e6241a853f7e2b2412a /usr.bin/xlint/lint1/func.c
parenta7fd65d5d46c64c757fd60fb55ef5e65322d3150 (diff)
Handle __dead functions using lint comments.
Diffstat (limited to 'usr.bin/xlint/lint1/func.c')
-rw-r--r--usr.bin/xlint/lint1/func.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c
index c3ee8e6350b..5d73a4e896b 100644
--- a/usr.bin/xlint/lint1/func.c
+++ b/usr.bin/xlint/lint1/func.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: func.c,v 1.9 2005/12/17 20:19:46 cloder Exp $ */
+/* $OpenBSD: func.c,v 1.10 2005/12/17 21:08:27 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.9 2005/12/17 20:19:46 cloder Exp $";
+static char rcsid[] = "$OpenBSD: func.c,v 1.10 2005/12/17 21:08:27 cloder Exp $";
#endif
#include <stdlib.h>
@@ -84,6 +84,12 @@ int nargusg = -1;
pos_t aupos;
/*
+ * If the following function has been declared NORETURN, noretflg is set
+ * to 1. Otherwise it is set to 0.
+ */
+int noretflg = 0;
+
+/*
* Number of arguments of the following function definition whose types
* shall be checked by lint2. -1 stands for all arguments.
*
@@ -387,6 +393,10 @@ funcend(void)
}
nargusg = -1;
+ if (noretflg)
+ funcsym->s_noreturn = 1;
+ noretflg = 0;
+
/*
* write the information about the function definition to the
* output file
@@ -1101,6 +1111,18 @@ argsused(int n)
}
/*
+ * NORETURN comment
+ *
+ * The following function will never return, which means any code
+ * following a call to this function is unreachable.
+ */
+void
+noreturn(int n)
+{
+ noretflg = 1;
+}
+
+/*
* VARARGS comment
*
* Makes that lint2 checks only the first n arguments for compatibility