summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-03-03 13:17:00 +0000
committermarkm <markm@FreeBSD.org>2002-03-03 13:17:00 +0000
commita9c0aaa0e8a6efa66f2c4364b24f1bf7520d9a53 (patch)
tree9ca989e7577c4407884daecc9836097ae6fccce0
parent97ea65b2cb83e7b5b2c4afcacc3a185482457c2a (diff)
downloadFreeBSD-src-a9c0aaa0e8a6efa66f2c4364b24f1bf7520d9a53.zip
FreeBSD-src-a9c0aaa0e8a6efa66f2c4364b24f1bf7520d9a53.tar.gz
Import of NetBSD's (x)lint, snapshotted at 2002-3-3.
-rw-r--r--usr.bin/xlint/Makefile2
-rw-r--r--usr.bin/xlint/Makefile.inc21
-rw-r--r--usr.bin/xlint/arch/alpha/targparam.h53
-rw-r--r--usr.bin/xlint/arch/amd64/targparam.h53
-rw-r--r--usr.bin/xlint/arch/arm/targparam.h63
-rw-r--r--usr.bin/xlint/arch/i386/targparam.h53
-rw-r--r--usr.bin/xlint/arch/m68000/targparam.h53
-rw-r--r--usr.bin/xlint/arch/m68k/targparam.h53
-rw-r--r--usr.bin/xlint/arch/mips/targparam.h53
-rw-r--r--usr.bin/xlint/arch/ns32k/targparam.h53
-rw-r--r--usr.bin/xlint/arch/powerpc/targparam.h53
-rw-r--r--usr.bin/xlint/arch/sh3/targparam.h53
-rw-r--r--usr.bin/xlint/arch/sparc/targparam.h53
-rw-r--r--usr.bin/xlint/arch/sparc64/targparam.h53
-rw-r--r--usr.bin/xlint/arch/vax/targparam.h53
-rw-r--r--usr.bin/xlint/arch/x86_64/targparam.h53
-rw-r--r--usr.bin/xlint/common/emit.c234
-rw-r--r--usr.bin/xlint/common/externs.h66
-rw-r--r--usr.bin/xlint/common/ilp32.h59
-rw-r--r--usr.bin/xlint/common/inittyp.c133
-rw-r--r--usr.bin/xlint/common/lint.h126
-rw-r--r--usr.bin/xlint/common/lp64.h59
-rw-r--r--usr.bin/xlint/common/mem.c88
-rw-r--r--usr.bin/xlint/common/param.h88
-rw-r--r--usr.bin/xlint/lint1/Makefile58
-rw-r--r--usr.bin/xlint/lint1/cgram.y210
-rw-r--r--usr.bin/xlint/lint1/decl.c521
-rw-r--r--usr.bin/xlint/lint1/emit1.c73
-rw-r--r--usr.bin/xlint/lint1/err.c128
-rw-r--r--usr.bin/xlint/lint1/externs1.h308
-rw-r--r--usr.bin/xlint/lint1/func.c180
-rw-r--r--usr.bin/xlint/lint1/init.c53
-rw-r--r--usr.bin/xlint/lint1/lint1.h50
-rw-r--r--usr.bin/xlint/lint1/main1.c70
-rw-r--r--usr.bin/xlint/lint1/makeman94
-rw-r--r--usr.bin/xlint/lint1/mem1.c80
-rw-r--r--usr.bin/xlint/lint1/op.h2
-rw-r--r--usr.bin/xlint/lint1/scan.l297
-rw-r--r--usr.bin/xlint/lint1/tree.c611
-rw-r--r--usr.bin/xlint/lint2/Makefile21
-rw-r--r--usr.bin/xlint/lint2/chk.c302
-rw-r--r--usr.bin/xlint/lint2/emit2.c103
-rw-r--r--usr.bin/xlint/lint2/externs2.h36
-rw-r--r--usr.bin/xlint/lint2/hash.c79
-rw-r--r--usr.bin/xlint/lint2/lint2.h25
-rw-r--r--usr.bin/xlint/lint2/main2.c26
-rw-r--r--usr.bin/xlint/lint2/mem2.c18
-rw-r--r--usr.bin/xlint/lint2/msg.c40
-rw-r--r--usr.bin/xlint/lint2/read.c278
-rw-r--r--usr.bin/xlint/llib/Makefile20
-rw-r--r--usr.bin/xlint/llib/llib-lposix2
-rw-r--r--usr.bin/xlint/llib/llib-lstdc2
-rw-r--r--usr.bin/xlint/xlint/Makefile21
-rw-r--r--usr.bin/xlint/xlint/lint.1161
-rw-r--r--usr.bin/xlint/xlint/pathnames.h7
-rw-r--r--usr.bin/xlint/xlint/xlint.c427
56 files changed, 4045 insertions, 1886 deletions
diff --git a/usr.bin/xlint/Makefile b/usr.bin/xlint/Makefile
index 01557ad..4ffb2dd 100644
--- a/usr.bin/xlint/Makefile
+++ b/usr.bin/xlint/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 1995/07/03 21:23:45 cgd Exp $
+# $NetBSD$
SUBDIR= lint1 lint2 xlint llib
diff --git a/usr.bin/xlint/Makefile.inc b/usr.bin/xlint/Makefile.inc
new file mode 100644
index 0000000..0a31de2
--- /dev/null
+++ b/usr.bin/xlint/Makefile.inc
@@ -0,0 +1,21 @@
+# $NetBSD: Makefile.inc,v 1.8 2002/02/04 00:18:32 thorpej Exp $
+
+.include <bsd.own.mk>
+
+.PATH: ${.CURDIR}/../common
+
+# On the m68000, MACHINE_CPU is "m68k", but we have different
+# target parameters (namely, long double is a different size
+# on the m68000), so we special case the directory name here.
+.if ${MACHINE_ARCH} == "m68000"
+ARCHSUBDIR= m68000
+.else
+ARCHSUBDIR= ${MACHINE_CPU}
+.endif
+
+CPPFLAGS+= -I${.CURDIR}/../arch/${ARCHSUBDIR}
+CPPFLAGS+= -I${.CURDIR}/../common
+
+.if exists(${.CURDIR}/../../Makefile.inc)
+.include "${.CURDIR}/../../Makefile.inc"
+.endif
diff --git a/usr.bin/xlint/arch/alpha/targparam.h b/usr.bin/xlint/arch/alpha/targparam.h
new file mode 100644
index 0000000..e31168e
--- /dev/null
+++ b/usr.bin/xlint/arch/alpha/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:18 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "lp64.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/amd64/targparam.h b/usr.bin/xlint/arch/amd64/targparam.h
new file mode 100644
index 0000000..8d57fbd
--- /dev/null
+++ b/usr.bin/xlint/arch/amd64/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.2 2002/01/30 06:55:00 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "lp64.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (16 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/arm/targparam.h b/usr.bin/xlint/arch/arm/targparam.h
new file mode 100644
index 0000000..d1d6f94
--- /dev/null
+++ b/usr.bin/xlint/arch/arm/targparam.h
@@ -0,0 +1,63 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#if defined(TARGET_OBJFMT_ELF)
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+#else
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+#endif
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#if defined(TARGET_OBJFMT_ELF)
+/* XXX ARM ELF ABI says packed enums -- variable size! */
+#define ENUM_SIZE (4 * CHAR_BIT)
+#else
+#define ENUM_SIZE (4 * CHAR_BIT)
+#endif
diff --git a/usr.bin/xlint/arch/i386/targparam.h b/usr.bin/xlint/arch/i386/targparam.h
new file mode 100644
index 0000000..86dfb19
--- /dev/null
+++ b/usr.bin/xlint/arch/i386/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (12 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/m68000/targparam.h b/usr.bin/xlint/arch/m68000/targparam.h
new file mode 100644
index 0000000..f79777d
--- /dev/null
+++ b/usr.bin/xlint/arch/m68000/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/m68k/targparam.h b/usr.bin/xlint/arch/m68k/targparam.h
new file mode 100644
index 0000000..86dfb19
--- /dev/null
+++ b/usr.bin/xlint/arch/m68k/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (12 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/mips/targparam.h b/usr.bin/xlint/arch/mips/targparam.h
new file mode 100644
index 0000000..7b6e056
--- /dev/null
+++ b/usr.bin/xlint/arch/mips/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:19 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/ns32k/targparam.h b/usr.bin/xlint/arch/ns32k/targparam.h
new file mode 100644
index 0000000..f6b3308
--- /dev/null
+++ b/usr.bin/xlint/arch/ns32k/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (12 * CHAR_BIT) /* XXX double-check */
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/powerpc/targparam.h b/usr.bin/xlint/arch/powerpc/targparam.h
new file mode 100644
index 0000000..d49eb76
--- /dev/null
+++ b/usr.bin/xlint/arch/powerpc/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/sh3/targparam.h b/usr.bin/xlint/arch/sh3/targparam.h
new file mode 100644
index 0000000..d49eb76
--- /dev/null
+++ b/usr.bin/xlint/arch/sh3/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:20 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/sparc/targparam.h b/usr.bin/xlint/arch/sparc/targparam.h
new file mode 100644
index 0000000..c0eabbd
--- /dev/null
+++ b/usr.bin/xlint/arch/sparc/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:21 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/sparc64/targparam.h b/usr.bin/xlint/arch/sparc64/targparam.h
new file mode 100644
index 0000000..8d57fbd
--- /dev/null
+++ b/usr.bin/xlint/arch/sparc64/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.2 2002/01/30 06:55:00 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "lp64.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (16 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/vax/targparam.h b/usr.bin/xlint/arch/vax/targparam.h
new file mode 100644
index 0000000..261369d
--- /dev/null
+++ b/usr.bin/xlint/arch/vax/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:22 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "ilp32.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 0
+#define SIZEOF_IS_ULONG 0
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (8 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/arch/x86_64/targparam.h b/usr.bin/xlint/arch/x86_64/targparam.h
new file mode 100644
index 0000000..6cfedcb
--- /dev/null
+++ b/usr.bin/xlint/arch/x86_64/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.1 2002/01/18 20:39:22 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "lp64.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (16 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/common/emit.c b/usr.bin/xlint/common/emit.c
new file mode 100644
index 0000000..9413433
--- /dev/null
+++ b/usr.bin/xlint/common/emit.c
@@ -0,0 +1,234 @@
+/* $NetBSD: emit.c,v 1.2 2002/01/21 19:49:51 tv Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: emit.c,v 1.2 2002/01/21 19:49:51 tv Exp $");
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "lint.h"
+
+/* name and handle of output file */
+static const char *loname;
+static FILE *lout;
+
+/* output buffer data */
+ob_t ob;
+
+static void outxbuf(void);
+
+
+/*
+ * initialize output
+ */
+void
+outopen(const char *name)
+{
+
+ loname = name;
+
+ /* Open output file */
+ if ((lout = fopen(name, "w")) == NULL)
+ err(1, "cannot open '%s'", name);
+
+ /* Create output buffer */
+ ob.o_len = 1024;
+ ob.o_end = (ob.o_buf = ob.o_nxt = xmalloc(ob.o_len)) + ob.o_len;
+}
+
+/*
+ * flush output buffer and close file
+ */
+void
+outclose(void)
+{
+
+ outclr();
+ if (fclose(lout) == EOF)
+ err(1, "cannot close '%s'", loname);
+}
+
+/*
+ * resize output buffer
+ */
+static void
+outxbuf(void)
+{
+ ptrdiff_t coffs;
+
+ coffs = ob.o_nxt - ob.o_buf;
+ ob.o_len *= 2;
+ ob.o_end = (ob.o_buf = xrealloc(ob.o_buf, ob.o_len)) + ob.o_len;
+ ob.o_nxt = ob.o_buf + coffs;
+}
+
+/*
+ * reset output buffer
+ * if it is not empty, it is flushed
+ */
+void
+outclr(void)
+{
+ size_t sz;
+
+ if (ob.o_buf != ob.o_nxt) {
+ outchar('\n');
+ sz = ob.o_nxt - ob.o_buf;
+ if (sz > ob.o_len)
+ errx(1, "internal error: outclr() 1");
+ if (fwrite(ob.o_buf, sz, 1, lout) != 1)
+ err(1, "cannot write to %s", loname);
+ ob.o_nxt = ob.o_buf;
+ }
+}
+
+/*
+ * write a character to the output buffer
+ */
+void
+outchar(int c)
+{
+
+ if (ob.o_nxt == ob.o_end)
+ outxbuf();
+ *ob.o_nxt++ = (char)c;
+}
+
+/*
+ * write a character to the output buffer, qouted if necessary
+ */
+void
+outqchar(int c)
+{
+
+ if (isprint(c) && c != '\\' && c != '"' && c != '\'') {
+ outchar(c);
+ } else {
+ outchar('\\');
+ switch (c) {
+ case '\\':
+ outchar('\\');
+ break;
+ case '"':
+ outchar('"');
+ break;
+ case '\'':
+ outchar('\'');
+ break;
+ case '\b':
+ outchar('b');
+ break;
+ case '\t':
+ outchar('t');
+ break;
+ case '\n':
+ outchar('n');
+ break;
+ case '\f':
+ outchar('f');
+ break;
+ case '\r':
+ outchar('r');
+ break;
+ case '\v':
+ outchar('v');
+ break;
+ case '\a':
+ outchar('a');
+ break;
+ default:
+ outchar((((u_int)c >> 6) & 07) + '0');
+ outchar((((u_int)c >> 3) & 07) + '0');
+ outchar((c & 07) + '0');
+ break;
+ }
+ }
+}
+
+/*
+ * write a strint to the output buffer
+ * the string must not contain any characters which
+ * should be quoted
+ */
+void
+outstrg(const char *s)
+{
+
+ while (*s != '\0') {
+ if (ob.o_nxt == ob.o_end)
+ outxbuf();
+ *ob.o_nxt++ = *s++;
+ }
+}
+
+/*
+ * write an integer value to toe output buffer
+ */
+void
+outint(int i)
+{
+
+ if ((ob.o_end - ob.o_nxt) < 3 * sizeof (int))
+ outxbuf();
+ ob.o_nxt += sprintf(ob.o_nxt, "%d", i);
+}
+
+/*
+ * write the name of a symbol to the output buffer
+ * the name is preceded by its length
+ */
+void
+outname(const char *name)
+{
+
+ if (name == NULL)
+ errx(1, "internal error: outname() 1");
+ outint((int)strlen(name));
+ outstrg(name);
+}
+
+/*
+ * write the name of the .c source
+ */
+void
+outsrc(const char *name)
+{
+
+ outclr();
+ outchar('S');
+ outstrg(name);
+}
diff --git a/usr.bin/xlint/common/externs.h b/usr.bin/xlint/common/externs.h
new file mode 100644
index 0000000..8c454b4
--- /dev/null
+++ b/usr.bin/xlint/common/externs.h
@@ -0,0 +1,66 @@
+/* $NetBSD: externs.h,v 1.1 2002/01/18 20:39:23 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * main[12].c
+ */
+extern int pflag;
+
+/*
+ * inittyp.c
+ */
+extern void inittyp(void);
+
+/*
+ * mem.c
+ */
+extern void *xmalloc(size_t);
+extern void *xcalloc(size_t, size_t);
+extern void *xrealloc(void *, size_t);
+extern char *xstrdup(const char *);
+extern void nomem(void);
+
+/*
+ * emit.c
+ */
+extern ob_t ob;
+
+extern void outopen(const char *);
+extern void outclose(void);
+extern void outclr(void);
+extern void outchar(int);
+extern void outqchar(int);
+extern void outstrg(const char *);
+extern void outint(int);
+extern void outname(const char *);
+extern void outsrc(const char *);
diff --git a/usr.bin/xlint/common/ilp32.h b/usr.bin/xlint/common/ilp32.h
new file mode 100644
index 0000000..5eb5f03
--- /dev/null
+++ b/usr.bin/xlint/common/ilp32.h
@@ -0,0 +1,59 @@
+/* $NetBSD: ilp32.h,v 1.1 2002/01/18 20:39:23 thorpej Exp $ */
+
+/*
+ * Copyright (c) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project by
+ * Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Type sizes for IPL32 platforms (int, long, pointer: 32-bit)
+ */
+
+#define CHAR_SIZE (CHAR_BIT)
+#define SHORT_SIZE (2 * CHAR_BIT)
+#define INT_SIZE (4 * CHAR_BIT)
+#define LONG_SIZE (4 * CHAR_BIT)
+#define QUAD_SIZE (8 * CHAR_BIT)
+#define PTR_SIZE (4 * CHAR_BIT)
+
+#define TARG_INT_MAX ((int32_t) (((uint32_t) -1) >> 1))
+#define TARG_INT_MIN ((-TARG_INT_MAX) - 1)
+#define TARG_UINT_MAX ((uint32_t) -1)
+
+#define TARG_LONG_MAX TARG_INT_MAX
+#define TARG_LONG_MIN TARG_INT_MIN
+#define TARG_ULONG_MAX TARG_UINT_MAX
+
+#define TARG_QUAD_MAX ((int64_t) (((uint64_t) -1) >> 1))
+#define TARG_QUAD_MIN ((-TARG_QUAD_MAX) - 1)
+#define TARG_UQUAD_MAX ((uint64_t) -1)
diff --git a/usr.bin/xlint/common/inittyp.c b/usr.bin/xlint/common/inittyp.c
new file mode 100644
index 0000000..b0958bf
--- /dev/null
+++ b/usr.bin/xlint/common/inittyp.c
@@ -0,0 +1,133 @@
+/* $NetBSD: inittyp.c,v 1.3 2002/01/30 06:55:02 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: inittyp.c,v 1.3 2002/01/30 06:55:02 thorpej Exp $");
+#endif
+
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include "lint.h"
+
+/* various type information */
+ttab_t ttab[NTSPEC];
+
+void
+inittyp(void)
+{
+ int i;
+ static const struct {
+ tspec_t it_tspec;
+ ttab_t it_ttab;
+ } ittab[NTSPEC] = {
+ { SIGNED, { 0, 0,
+ SIGNED, UNSIGN,
+ 0, 0, 0, 0, 0, "signed" } },
+ { UNSIGN, { 0, 0,
+ SIGNED, UNSIGN,
+ 0, 0, 0, 0, 0, "unsigned" } },
+ { CHAR, { CHAR_SIZE, CHAR_BIT,
+ SCHAR, UCHAR,
+ 1, 0, 0, 1, 1, "char" } },
+ { SCHAR, { CHAR_SIZE, CHAR_BIT,
+ SCHAR, UCHAR,
+ 1, 0, 0, 1, 1, "signed char" } },
+ { UCHAR, { CHAR_SIZE, CHAR_BIT,
+ SCHAR, UCHAR,
+ 1, 1, 0, 1, 1, "unsigned char" } },
+ { SHORT, { SHORT_SIZE, 2 * CHAR_BIT,
+ SHORT, USHORT,
+ 1, 0, 0, 1, 1, "short" } },
+ { USHORT, { SHORT_SIZE, 2 * CHAR_BIT,
+ SHORT, USHORT,
+ 1, 1, 0, 1, 1, "unsigned short" } },
+ { INT, { INT_SIZE, 3 * CHAR_BIT,
+ INT, UINT,
+ 1, 0, 0, 1, 1, "int" } },
+ { UINT, { INT_SIZE, 3 * CHAR_BIT,
+ INT, UINT,
+ 1, 1, 0, 1, 1, "unsigned int" } },
+ { LONG, { LONG_SIZE, 4 * CHAR_BIT,
+ LONG, ULONG,
+ 1, 0, 0, 1, 1, "long" } },
+ { ULONG, { LONG_SIZE, 4 * CHAR_BIT,
+ LONG, ULONG,
+ 1, 1, 0, 1, 1, "unsigned long" } },
+ { QUAD, { QUAD_SIZE, 8 * CHAR_BIT,
+ QUAD, UQUAD,
+ 1, 0, 0, 1, 1, "long long" } },
+ { UQUAD, { QUAD_SIZE, 8 * CHAR_BIT,
+ QUAD, UQUAD,
+ 1, 1, 0, 1, 1, "unsigned long long" } },
+ { FLOAT, { FLOAT_SIZE, 4 * CHAR_BIT,
+ FLOAT, FLOAT,
+ 0, 0, 1, 1, 1, "float" } },
+ { DOUBLE, { DOUBLE_SIZE, 8 * CHAR_BIT,
+ DOUBLE, DOUBLE,
+ 0, 0, 1, 1, 1, "double" } },
+ { LDOUBLE, { LDOUBLE_SIZE, 10 * CHAR_BIT,
+ LDOUBLE, LDOUBLE,
+ 0, 0, 1, 1, 1, "long double" } },
+ { VOID, { -1, -1,
+ VOID, VOID,
+ 0, 0, 0, 0, 0, "void" } },
+ { STRUCT, { -1, -1,
+ STRUCT, STRUCT,
+ 0, 0, 0, 0, 0, "struct" } },
+ { UNION, { -1, -1,
+ UNION, UNION,
+ 0, 0, 0, 0, 0, "union" } },
+ { ENUM, { ENUM_SIZE, 3 * CHAR_BIT,
+ ENUM, ENUM,
+ 1, 0, 0, 1, 1, "enum" } },
+ { PTR, { PTR_SIZE, 4 * CHAR_BIT,
+ PTR, PTR,
+ 0, 1, 0, 0, 1, "pointer" } },
+ { ARRAY, { -1, -1,
+ ARRAY, ARRAY,
+ 0, 0, 0, 0, 0, "array" } },
+ { FUNC, { -1, -1,
+ FUNC, FUNC,
+ 0, 0, 0, 0, 0, "function" } },
+ };
+
+ for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
+ STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
+ if (!pflag) {
+ for (i = 0; i < NTSPEC; i++)
+ ttab[i].tt_psz = ttab[i].tt_sz;
+ }
+}
diff --git a/usr.bin/xlint/common/lint.h b/usr.bin/xlint/common/lint.h
new file mode 100644
index 0000000..c73f73c
--- /dev/null
+++ b/usr.bin/xlint/common/lint.h
@@ -0,0 +1,126 @@
+/* $NetBSD: lint.h,v 1.3 2002/01/31 22:44:00 tv Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#else
+#define HAVE_DECL_SYS_SIGNAME 1
+#endif
+
+#include <sys/types.h>
+#include <stddef.h>
+#include <err.h>
+#include <inttypes.h>
+#include <stdio.h>
+
+#include "param.h"
+
+/*
+ * Type specifiers, used in type structures (type_t) and otherwere.
+ */
+typedef enum {
+ NOTSPEC = 0,
+ SIGNED, /* keyword "signed", only used in the parser */
+ UNSIGN, /* keyword "unsigned", only used in the parser */
+ CHAR, /* char */
+ SCHAR, /* signed char */
+ UCHAR, /* unsigned char */
+ SHORT, /* (signed) short */
+ USHORT, /* unsigned short */
+ INT, /* (signed) int */
+ UINT, /* unsigned int */
+ LONG, /* (signed) long */
+ ULONG, /* unsigned long */
+ QUAD, /* (signed) long long */
+ UQUAD, /* unsigned long long */
+ FLOAT, /* float */
+ DOUBLE, /* double or, with tflag, long float */
+ LDOUBLE, /* long double */
+ VOID, /* void */
+ STRUCT, /* structure tag */
+ UNION, /* union tag */
+ ENUM, /* enum tag */
+ PTR, /* pointer */
+ ARRAY, /* array */
+ FUNC, /* function */
+ NTSPEC
+} tspec_t;
+
+/*
+ * size of types, name and classification
+ */
+typedef struct {
+ int tt_sz; /* size in bits */
+ int tt_psz; /* size, different from tt_sz
+ if pflag is set */
+ tspec_t tt_styp; /* signed counterpart */
+ tspec_t tt_utyp; /* unsigned counterpart */
+ u_int tt_isityp : 1; /* 1 if integer type */
+ u_int tt_isutyp : 1; /* 1 if unsigned integer type */
+ u_int tt_isftyp : 1; /* 1 if floating point type */
+ u_int tt_isatyp : 1; /* 1 if arithmetic type */
+ u_int tt_issclt : 1; /* 1 if scalar type */
+ char *tt_name; /* Bezeichnung des Typs */
+} ttab_t;
+
+#define size(t) (ttab[t].tt_sz)
+#define psize(t) (ttab[t].tt_psz)
+#define styp(t) (ttab[t].tt_styp)
+#define utyp(t) (ttab[t].tt_utyp)
+#define isityp(t) (ttab[t].tt_isityp)
+#define isutyp(t) (ttab[t].tt_isutyp)
+#define isftyp(t) (ttab[t].tt_isftyp)
+#define isatyp(t) (ttab[t].tt_isatyp)
+#define issclt(t) (ttab[t].tt_issclt)
+
+extern ttab_t ttab[];
+
+
+typedef enum {
+ NODECL, /* until now not declared */
+ DECL, /* declared */
+ TDEF, /* tentative defined */
+ DEF /* defined */
+} def_t;
+
+/*
+ * Following structure contains some data used for the output buffer.
+ */
+typedef struct ob {
+ char *o_buf; /* buffer */
+ char *o_end; /* first byte after buffer */
+ size_t o_len; /* length of buffer */
+ char *o_nxt; /* next free byte in buffer */
+} ob_t;
+
+#include "externs.h"
diff --git a/usr.bin/xlint/common/lp64.h b/usr.bin/xlint/common/lp64.h
new file mode 100644
index 0000000..cd88700
--- /dev/null
+++ b/usr.bin/xlint/common/lp64.h
@@ -0,0 +1,59 @@
+/* $NetBSD: lp64.h,v 1.1 2002/01/18 20:39:23 thorpej Exp $ */
+
+/*
+ * Copyright (c) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project by
+ * Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Type sizes for LP64 platforms (long, pointer: 64-bit)
+ */
+
+#define CHAR_SIZE (CHAR_BIT)
+#define SHORT_SIZE (2 * CHAR_BIT)
+#define INT_SIZE (4 * CHAR_BIT)
+#define LONG_SIZE (8 * CHAR_BIT)
+#define QUAD_SIZE (8 * CHAR_BIT)
+#define PTR_SIZE (8 * CHAR_BIT)
+
+#define TARG_INT_MAX ((int32_t) (((uint32_t) -1) >> 1))
+#define TARG_INT_MIN ((-TARG_INT_MAX) - 1)
+#define TARG_UINT_MAX ((uint32_t) -1)
+
+#define TARG_QUAD_MAX ((int64_t) (((uint64_t) -1) >> 1))
+#define TARG_QUAD_MIN ((-TARG_QUAD_MAX) - 1)
+#define TARG_UQUAD_MAX ((uint64_t) -1)
+
+#define TARG_LONG_MAX TARG_QUAD_MAX
+#define TARG_LONG_MIN TARG_QUAD_MIN
+#define TARG_ULONG_MAX TARG_UQUAD_MAX
diff --git a/usr.bin/xlint/common/mem.c b/usr.bin/xlint/common/mem.c
new file mode 100644
index 0000000..2621081
--- /dev/null
+++ b/usr.bin/xlint/common/mem.c
@@ -0,0 +1,88 @@
+/* $NetBSD: mem.c,v 1.2 2002/01/21 19:49:51 tv Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: mem.c,v 1.2 2002/01/21 19:49:51 tv Exp $");
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "lint.h"
+
+void *
+xmalloc(size_t s)
+{
+ void *p;
+
+ if ((p = malloc(s)) == NULL)
+ nomem();
+ return (p);
+}
+
+void *
+xcalloc(size_t n, size_t s)
+{
+ void *p;
+
+ if ((p = calloc(n, s)) == NULL)
+ nomem();
+ return (p);
+}
+
+void *
+xrealloc(void *p, size_t s)
+{
+
+ if ((p = realloc(p, s)) == NULL)
+ nomem();
+ return (p);
+}
+
+char *
+xstrdup(const char *s)
+{
+ char *s2;
+
+ if ((s2 = strdup(s)) == NULL)
+ nomem();
+ return (s2);
+}
+
+void
+nomem(void)
+{
+
+ errx(1, "virtual memory exhausted");
+}
diff --git a/usr.bin/xlint/common/param.h b/usr.bin/xlint/common/param.h
new file mode 100644
index 0000000..46f7326
--- /dev/null
+++ b/usr.bin/xlint/common/param.h
@@ -0,0 +1,88 @@
+/* $NetBSD: param.h,v 1.1 2002/01/18 20:39:24 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Minimun size of string buffer. If this is not enough, the buffer
+ * is enlarged in steps of STRBLEN bytes.
+ */
+#define STRBLEN 256
+
+/*
+ * This defines the size of memory blocks which are used to allocate
+ * memory in larger chunks.
+ */
+#define MBLKSIZ ((size_t)0x4000)
+
+/*
+ * Sizes of hash tables
+ * Should be a prime. Possible primes are
+ * 307, 401, 503, 601, 701, 809, 907, 1009, 1103, 1201, 1301, 1409, 1511.
+ *
+ * HSHSIZ1 symbol table 1st pass
+ * HSHSIZ2 symbol table 2nd pass
+ * THSHSIZ2 type table 2nd pass
+ */
+#define HSHSIZ1 503
+#define HSHSIZ2 1009
+#define THSHSIZ2 1009
+
+/*
+ * Pull in target-specific parameters.
+ */
+#include "targparam.h"
+
+/*
+ * Make sure this matches wchar_t.
+ */
+#define WCHAR INT
+
+/*
+ * long double only in ANSI C.
+ *
+ * And the sparc64 long double code generation is broken.
+ */
+#if !defined(__sparc64__) && defined(__STDC__)
+typedef long double ldbl_t;
+#else
+typedef double ldbl_t;
+#endif
+
+/*
+ * Some traditional compilers are not able to assign structures.
+ */
+#ifdef __STDC__
+#define STRUCT_ASSIGN(dest, src) (dest) = (src)
+#else
+#define STRUCT_ASSIGN(dest, src) (void)memcpy(&(dest), &(src), \
+ sizeof (dest));
+#endif
diff --git a/usr.bin/xlint/lint1/Makefile b/usr.bin/xlint/lint1/Makefile
index d5e519a..6c8a68f 100644
--- a/usr.bin/xlint/lint1/Makefile
+++ b/usr.bin/xlint/lint1/Makefile
@@ -1,19 +1,49 @@
-# $NetBSD: Makefile,v 1.3 1995/07/04 01:53:05 cgd Exp $
+# $NetBSD: Makefile,v 1.25 2002/02/01 01:32:20 ross Exp $
-PROG= lint1
-SRCS= cgram.c scan.c mem1.c mem.c err.c main1.c decl.c tree.c func.c \
- init.c emit.c emit1.c
-NOMAN=
-LDADD+= -ll
-DPADD+= ${LIBL}
-YFLAGS= -d
-CFLAGS+=-I.
-LINTFLAGS=-aehpz
-CLEANFILES+=y.tab.h cgram.c scan.c
+.include <bsd.own.mk>
-BINDIR= /usr/libexec
+PROG= lint1
+SRCS= cgram.y scan.l mem1.c mem.c err.c main1.c decl.c tree.c func.c \
+ init.c emit.c emit1.c inittyp.c
+MAN= lint.7
+YHEADER=
-# XXX: -O causes the gcc to die on the i386, when compiling tree.o
-CFLAGS+= -DXXX_BROKEN_GCC
+CPPFLAGS+= -I${.CURDIR} -I.
+
+.if ${OBJECT_FMT} == "a.out"
+CPPFLAGS+= -DTARGET_OBJFMT_AOUT
+.elif ${OBJECT_FMT} == "COFF"
+CPPFLAGS+= -DTARGET_OBJFMT_COFF
+.elif ${OBJECT_FMT} == "ELF"
+CPPFLAGS+= -DTARGET_OBJFMT_ELF
+.else
+.BEGIN:
+ @echo "Unrecognized OBJECT_FMT ${OBJECT_FMT}"
+ @false
+.endif
+
+LINTFLAGS= -aehpz
+WFORMAT=1 #hopeless
+BINDIR= /usr/libexec
+
+scan.c: cgram.h
+
+CLEANFILES+= ${MAN}
+
+.if ${USETOOLS} == "yes"
+LINT1= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
+.endif
+LINT1?= ./${PROG}
+
+${MAN}: makeman ${LINT1:C/^\.\///} Makefile
+ sh ${.ALLSRC:M*makeman} ${LINT1} -m >${.TARGET}
+
+LDADD+= -lm
+DPADD+= ${LIBM}
+
+.ifndef HOSTPROG
+LDADD+= -ll
+DPADD+= ${LIBL}
.include <bsd.prog.mk>
+.endif
diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y
index e65584a..9fdc58c 100644
--- a/usr.bin/xlint/lint1/cgram.y
+++ b/usr.bin/xlint/lint1/cgram.y
@@ -1,7 +1,8 @@
%{
-/* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $ */
+/* $NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -32,11 +33,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $");
#endif
#include <stdlib.h>
+#include <string.h>
#include <limits.h>
#include "lint1.h"
@@ -55,10 +58,52 @@ int blklev;
*/
int mblklev;
-static int toicon __P((tnode_t *));
-static void idecl __P((sym_t *, int));
-static void ignuptorp __P((void));
+/*
+ * Save the no-warns state and restore it to avoid the problem where
+ * if (expr) { stmt } / * NOLINT * / stmt;
+ */
+static int onowarn = -1;
+
+static int toicon(tnode_t *);
+static void idecl(sym_t *, int, sbuf_t *);
+static void ignuptorp(void);
+
+#ifdef DEBUG
+static __inline void CLRWFLGS(void);
+static __inline void CLRWFLGS(void)
+{
+ printf("%s, %d: clear flags %s %d\n", curr_pos.p_file,
+ curr_pos.p_line, __FILE__, __LINE__);
+ clrwflgs();
+ onowarn = -1;
+}
+static __inline void SAVE(void);
+static __inline void SAVE(void)
+{
+ if (onowarn != -1)
+ abort();
+ printf("%s, %d: save flags %s %d = %d\n", curr_pos.p_file,
+ curr_pos.p_line, __FILE__, __LINE__, nowarn);
+ onowarn = nowarn;
+}
+
+static __inline void RESTORE(void);
+static __inline void RESTORE(void)
+{
+ if (onowarn != -1) {
+ nowarn = onowarn;
+ printf("%s, %d: restore flags %s %d = %d\n", curr_pos.p_file,
+ curr_pos.p_line, __FILE__, __LINE__, nowarn);
+ onowarn = -1;
+ } else
+ CLRWFLGS();
+}
+#else
+#define CLRWFLGS() clrwflgs(), onowarn = -1
+#define SAVE() onowarn = nowarn
+#define RESTORE() (void)(onowarn == -1 ? (clrwflgs(), 0) : (nowarn = onowarn))
+#endif
%}
%union {
@@ -129,6 +174,7 @@ static void ignuptorp __P((void));
%token T_BREAK
%token T_RETURN
%token T_ASM
+%token T_SYMBOLRENAME
%left T_COMMA
%right T_ASSIGN T_OPASS
@@ -205,6 +251,7 @@ static void ignuptorp __P((void));
%type <y_tnode> opt_expr
%type <y_strg> string
%type <y_strg> string2
+%type <y_sb> opt_asm_or_symbolrename
%%
@@ -228,13 +275,14 @@ translation_unit:
;
ext_decl:
- func_def {
+ asm_stmnt
+ | func_def {
glclup(0);
- clrwflgs();
+ CLRWFLGS();
}
| data_def {
glclup(0);
- clrwflgs();
+ CLRWFLGS();
}
;
@@ -278,7 +326,7 @@ data_def:
}
| declspecs deftyp type_init_decls T_SEMI
| error T_SEMI {
- globclup();
+ globclup();
}
| error T_RBRACE {
globclup();
@@ -712,7 +760,7 @@ enums_with_opt_comma:
error(54);
} else {
/* trailing "," prohibited in enum declaration */
- warning(54);
+ (void)gnuism(54);
}
$$ = $1;
}
@@ -757,24 +805,24 @@ type_init_decls:
;
notype_init_decl:
- notype_decl opt_asm_spec {
- idecl($1, 0);
+ notype_decl opt_asm_or_symbolrename {
+ idecl($1, 0, $2);
chksz($1);
}
- | notype_decl opt_asm_spec {
- idecl($1, 1);
+ | notype_decl opt_asm_or_symbolrename {
+ idecl($1, 1, $2);
} T_ASSIGN initializer {
chksz($1);
}
;
type_init_decl:
- type_decl opt_asm_spec {
- idecl($1, 0);
+ type_decl opt_asm_or_symbolrename {
+ idecl($1, 0, $2);
chksz($1);
}
- | type_decl opt_asm_spec {
- idecl($1, 1);
+ | type_decl opt_asm_or_symbolrename {
+ idecl($1, 1, $2);
} T_ASSIGN initializer {
chksz($1);
}
@@ -1015,10 +1063,10 @@ vararg_parameter_type_list:
;
parameter_type_list:
- parameter_declaration opt_asm_spec {
+ parameter_declaration {
$$ = $1;
}
- | parameter_type_list T_COMMA parameter_declaration opt_asm_spec {
+ | parameter_type_list T_COMMA parameter_declaration {
$$ = lnklst($1, $3);
}
;
@@ -1051,10 +1099,16 @@ parameter_declaration:
}
;
-opt_asm_spec:
- /* empty */
+opt_asm_or_symbolrename: /* expect only one */
+ /* empty */ {
+ $$ = NULL;
+ }
| T_ASM T_LPARN T_STRING T_RPARN {
freeyyv(&$3, T_STRING);
+ $$ = NULL;
+ }
+ | T_SYMBOLRENAME T_LPARN T_NAME T_RPARN {
+ $$ = $3;
}
;
@@ -1212,15 +1266,11 @@ opt_stmnt_list:
;
stmnt_list:
- stmnt {
- clrwflgs();
- }
+ stmnt
| stmnt_list stmnt {
- clrwflgs();
- }
- | stmnt_list error T_SEMI {
- clrwflgs();
+ RESTORE();
}
+ | stmnt_list error T_SEMI
;
expr_stmnt:
@@ -1235,21 +1285,27 @@ expr_stmnt:
selection_stmnt:
if_without_else {
+ SAVE();
if2();
if3(0);
}
| if_without_else T_ELSE {
+ SAVE();
if2();
} stmnt {
+ CLRWFLGS();
if3(1);
}
| if_without_else T_ELSE error {
+ CLRWFLGS();
if3(0);
}
| switch_expr stmnt {
+ CLRWFLGS();
switch2();
}
| switch_expr error {
+ CLRWFLGS();
switch2();
}
;
@@ -1262,35 +1318,46 @@ if_without_else:
if_expr:
T_IF T_LPARN expr T_RPARN {
if1($3);
- clrwflgs();
+ CLRWFLGS();
}
;
switch_expr:
T_SWITCH T_LPARN expr T_RPARN {
switch1($3);
- clrwflgs();
+ CLRWFLGS();
+ }
+ ;
+
+do_stmnt:
+ do stmnt {
+ CLRWFLGS();
}
;
iteration_stmnt:
while_expr stmnt {
+ CLRWFLGS();
while2();
}
| while_expr error {
+ CLRWFLGS();
while2();
}
- | do stmnt do_while_expr {
- do2($3);
+ | do_stmnt do_while_expr {
+ do2($2);
ftflg = 0;
}
| do error {
+ CLRWFLGS();
do2(NULL);
}
| for_exprs stmnt {
+ CLRWFLGS();
for2();
}
| for_exprs error {
+ CLRWFLGS();
for2();
}
;
@@ -1298,7 +1365,7 @@ iteration_stmnt:
while_expr:
T_WHILE T_LPARN expr T_RPARN {
while1($3);
- clrwflgs();
+ CLRWFLGS();
}
;
@@ -1317,7 +1384,7 @@ do_while_expr:
for_exprs:
T_FOR T_LPARN opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPARN {
for1($3, $5, $7);
- clrwflgs();
+ CLRWFLGS();
}
;
@@ -1375,10 +1442,10 @@ read_until_rparn:
declaration_list:
declaration {
- clrwflgs();
+ CLRWFLGS();
}
| declaration_list declaration {
- clrwflgs();
+ CLRWFLGS();
}
;
@@ -1441,7 +1508,7 @@ expr:
term:
T_NAME {
- /* XXX realy neccessary? */
+ /* XXX really necessary? */
if (yychar < 0)
yychar = yylex();
$$ = getnnode(getsym($1), yychar);
@@ -1565,15 +1632,34 @@ identifier:
/* ARGSUSED */
int
-yyerror(msg)
- char *msg;
+yyerror(char *msg)
{
+
error(249);
if (++sytxerr >= 5)
norecover();
return (0);
}
+static inline int uq_gt(uint64_t, uint64_t);
+static inline int q_gt(int64_t, int64_t);
+
+static inline int
+uq_gt(uint64_t a, uint64_t b)
+{
+
+ return (a > b);
+}
+
+static inline int
+q_gt(int64_t a, int64_t b)
+{
+
+ return (a > b);
+}
+
+#define q_lt(a, b) q_gt(b, a)
+
/*
* Gets a node for a constant and returns the value of this constant
* as integer.
@@ -1584,8 +1670,7 @@ yyerror(msg)
* expressions, it frees the memory used for the expression.
*/
static int
-toicon(tn)
- tnode_t *tn;
+toicon(tnode_t *tn)
{
int i;
tspec_t t;
@@ -1607,12 +1692,14 @@ toicon(tn)
} else {
i = (int)v->v_quad;
if (isutyp(t)) {
- if ((u_quad_t)v->v_quad > INT_MAX) {
+ if (uq_gt((uint64_t)v->v_quad,
+ (uint64_t)INT_MAX)) {
/* integral constant too large */
warning(56);
}
} else {
- if (v->v_quad > INT_MAX || v->v_quad < INT_MIN) {
+ if (q_gt(v->v_quad, (int64_t)INT_MAX) ||
+ q_lt(v->v_quad, (int64_t)INT_MIN)) {
/* integral constant too large */
warning(56);
}
@@ -1623,25 +1710,46 @@ toicon(tn)
}
static void
-idecl(decl, initflg)
- sym_t *decl;
- int initflg;
+idecl(sym_t *decl, int initflg, sbuf_t *rename)
{
+ char *s;
+
initerr = 0;
initsym = decl;
switch (dcs->d_ctx) {
case EXTERN:
+ if (rename != NULL) {
+ if (decl->s_rename != NULL)
+ lerror("idecl() 1");
+
+ s = getlblk(1, rename->sb_len + 1);
+ (void)memcpy(s, rename->sb_name, rename->sb_len + 1);
+ decl->s_rename = s;
+ freeyyv(&rename, T_NAME);
+ }
decl1ext(decl, initflg);
break;
case ARG:
+ if (rename != NULL) {
+ /* symbol renaming can't be used on function arguments */
+ error(310);
+ freeyyv(&rename, T_NAME);
+ break;
+ }
(void)decl1arg(decl, initflg);
break;
case AUTO:
+ if (rename != NULL) {
+ /* symbol renaming can't be used on automatic variables */
+ error(311);
+ freeyyv(&rename, T_NAME);
+ break;
+ }
decl1loc(decl, initflg);
break;
default:
- lerror("idecl()");
+ lerror("idecl() 2");
}
if (initflg && !initerr)
@@ -1652,8 +1760,8 @@ idecl(decl, initflg)
* Discard all input tokens up to and including the next
* unmatched right paren
*/
-void
-ignuptorp()
+static void
+ignuptorp(void)
{
int level;
diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c
index fa023b7..a77a561 100644
--- a/usr.bin/xlint/lint1/decl.c
+++ b/usr.bin/xlint/lint1/decl.c
@@ -1,6 +1,7 @@
-/* $NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $ */
+/* $NetBSD: decl.c,v 1.29 2002/01/18 21:01:39 thorpej Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -31,8 +32,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: decl.c,v 1.29 2002/01/18 21:01:39 thorpej Exp $");
#endif
#include <sys/param.h>
@@ -44,9 +46,6 @@ static char rcsid[] = "$NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $";
const char *unnamed = "<unnamed>";
-/* contains various information and classification on types */
-ttab_t ttab[NTSPEC];
-
/* shared type structures for arithmtic types and void */
static type_t *typetab;
@@ -59,107 +58,33 @@ int enumval;
*/
dinfo_t *dcs;
-static type_t *tdeferr __P((type_t *, tspec_t));
-static void settdsym __P((type_t *, sym_t *));
-static tspec_t mrgtspec __P((tspec_t, tspec_t));
-static void align __P((int, int));
-static sym_t *newtag __P((sym_t *, scl_t, int, int));
-static int eqargs __P((type_t *, type_t *, int *));
-static int mnoarg __P((type_t *, int *));
-static int chkosdef __P((sym_t *, sym_t *));
-static int chkptdecl __P((sym_t *, sym_t *));
-static sym_t *nsfunc __P((sym_t *, sym_t *));
-static void osfunc __P((sym_t *, sym_t *));
-static void ledecl __P((sym_t *));
-static int chkinit __P((sym_t *));
-static void chkausg __P((int, sym_t *));
-static void chkvusg __P((int, sym_t *));
-static void chklusg __P((sym_t *));
-static void chktusg __P((sym_t *));
-static void chkglvar __P((sym_t *));
-static void glchksz __P((sym_t *));
+static type_t *tdeferr(type_t *, tspec_t);
+static void settdsym(type_t *, sym_t *);
+static tspec_t mrgtspec(tspec_t, tspec_t);
+static void align(int, int);
+static sym_t *newtag(sym_t *, scl_t, int, int);
+static int eqargs(type_t *, type_t *, int *);
+static int mnoarg(type_t *, int *);
+static int chkosdef(sym_t *, sym_t *);
+static int chkptdecl(sym_t *, sym_t *);
+static sym_t *nsfunc(sym_t *, sym_t *);
+static void osfunc(sym_t *, sym_t *);
+static void ledecl(sym_t *);
+static int chkinit(sym_t *);
+static void chkausg(int, sym_t *);
+static void chkvusg(int, sym_t *);
+static void chklusg(sym_t *);
+static void chktusg(sym_t *);
+static void chkglvar(sym_t *);
+static void glchksz(sym_t *);
/*
* initializes all global vars used in declarations
*/
void
-initdecl()
-{
- int i;
- static struct {
- tspec_t it_tspec;
- ttab_t it_ttab;
- } ittab[] = {
- { SIGNED, { 0, 0,
- SIGNED, UNSIGN,
- 0, 0, 0, 0, 0, "signed" } },
- { UNSIGN, { 0, 0,
- SIGNED, UNSIGN,
- 0, 0, 0, 0, 0, "unsigned" } },
- { CHAR, { CHAR_BIT, CHAR_BIT,
- SCHAR, UCHAR,
- 1, 0, 0, 1, 1, "char" } },
- { SCHAR, { CHAR_BIT, CHAR_BIT,
- SCHAR, UCHAR,
- 1, 0, 0, 1, 1, "signed char" } },
- { UCHAR, { CHAR_BIT, CHAR_BIT,
- SCHAR, UCHAR,
- 1, 1, 0, 1, 1, "unsigned char" } },
- { SHORT, { sizeof (short) * CHAR_BIT, 2 * CHAR_BIT,
- SHORT, USHORT,
- 1, 0, 0, 1, 1, "short" } },
- { USHORT, { sizeof (u_short) * CHAR_BIT, 2 * CHAR_BIT,
- SHORT, USHORT,
- 1, 1, 0, 1, 1, "unsigned short" } },
- { INT, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
- INT, UINT,
- 1, 0, 0, 1, 1, "int" } },
- { UINT, { sizeof (u_int) * CHAR_BIT, 3 * CHAR_BIT,
- INT, UINT,
- 1, 1, 0, 1, 1, "unsigned int" } },
- { LONG, { sizeof (long) * CHAR_BIT, 4 * CHAR_BIT,
- LONG, ULONG,
- 1, 0, 0, 1, 1, "long" } },
- { ULONG, { sizeof (u_long) * CHAR_BIT, 4 * CHAR_BIT,
- LONG, ULONG,
- 1, 1, 0, 1, 1, "unsigned long" } },
- { QUAD, { sizeof (quad_t) * CHAR_BIT, 8 * CHAR_BIT,
- QUAD, UQUAD,
- 1, 0, 0, 1, 1, "long long" } },
- { UQUAD, { sizeof (u_quad_t) * CHAR_BIT, 8 * CHAR_BIT,
- QUAD, UQUAD,
- 1, 1, 0, 1, 1, "unsigned long long" } },
- { FLOAT, { sizeof (float) * CHAR_BIT, 4 * CHAR_BIT,
- FLOAT, FLOAT,
- 0, 0, 1, 1, 1, "float" } },
- { DOUBLE, { sizeof (double) * CHAR_BIT, 8 * CHAR_BIT,
- DOUBLE, DOUBLE,
- 0, 0, 1, 1, 1, "double" } },
- { LDOUBLE, { sizeof (ldbl_t) * CHAR_BIT, 10 * CHAR_BIT,
- LDOUBLE, LDOUBLE,
- 0, 0, 1, 1, 1, "long double" } },
- { VOID, { -1, -1,
- VOID, VOID,
- 0, 0, 0, 0, 0, "void" } },
- { STRUCT, { -1, -1,
- STRUCT, STRUCT,
- 0, 0, 0, 0, 0, "struct" } },
- { UNION, { -1, -1,
- UNION, UNION,
- 0, 0, 0, 0, 0, "union" } },
- { ENUM, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
- ENUM, ENUM,
- 1, 0, 0, 1, 1, "enum" } },
- { PTR, { sizeof (void *) * CHAR_BIT, 4 * CHAR_BIT,
- PTR, PTR,
- 0, 1, 0, 0, 1, "pointer" } },
- { ARRAY, { -1, -1,
- ARRAY, ARRAY,
- 0, 0, 0, 0, 0, "array" } },
- { FUNC, { -1, -1,
- FUNC, FUNC,
- 0, 0, 0, 0, 0, "function" } },
- };
+initdecl(void)
+{
+ int i;
/* declaration stack */
dcs = xcalloc(1, sizeof (dinfo_t));
@@ -167,13 +92,8 @@ initdecl()
dcs->d_ldlsym = &dcs->d_dlsyms;
/* type information and classification */
- for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
- STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
- if (!pflag) {
- for (i = 0; i < NTSPEC; i++)
- ttab[i].tt_psz = ttab[i].tt_sz;
- }
-
+ inittyp();
+
/* shared type structures */
typetab = xcalloc(NTSPEC, sizeof (type_t));
for (i = 0; i < NTSPEC; i++)
@@ -208,15 +128,14 @@ initdecl()
* if it is to be modified (adding qualifiers or anything else).
*/
type_t *
-gettyp(t)
- tspec_t t;
+gettyp(tspec_t t)
{
+
return (&typetab[t]);
}
type_t *
-duptyp(tp)
- const type_t *tp;
+duptyp(const type_t *tp)
{
type_t *ntp;
@@ -230,8 +149,7 @@ duptyp(tp)
* allocated memory should be freed after the expr).
*/
type_t *
-tduptyp(tp)
- const type_t *tp;
+tduptyp(const type_t *tp)
{
type_t *ntp;
@@ -245,8 +163,7 @@ tduptyp(tp)
* struct, union or enum type.
*/
int
-incompl(tp)
- type_t *tp;
+incompl(type_t *tp)
{
tspec_t t;
@@ -267,9 +184,7 @@ incompl(tp)
* types.
*/
void
-setcompl(tp, ic)
- type_t *tp;
- int ic;
+setcompl(type_t *tp, int ic)
{
tspec_t t;
@@ -290,9 +205,9 @@ setcompl(tp, ic)
* storage classes.
*/
void
-addscl(sc)
- scl_t sc;
+addscl(scl_t sc)
{
+
if (sc == INLINE) {
if (dcs->d_inline)
/* duplicate '%s' */
@@ -327,8 +242,7 @@ addscl(sc)
* struct/union/enum tag.
*/
void
-addtype(tp)
- type_t *tp;
+addtype(type_t *tp)
{
tspec_t t;
@@ -394,7 +308,7 @@ addtype(tp)
/* remeber specifiers "signed" and "unsigned" in dcs->d_smod */
if (dcs->d_smod != NOTSPEC)
/*
- * more then one "signed" and/or "unsigned"; print
+ * more than one "signed" and/or "unsigned"; print
* an error in deftyp()
*/
dcs->d_terr = 1;
@@ -411,7 +325,7 @@ addtype(tp)
} else {
/*
* remember specifiers "void", "char", "int", "float" or
- * "double" int dcs->d_atyp
+ * "double" int dcs->d_atyp
*/
if (dcs->d_atyp != NOTSPEC)
/* more than one, print error in deftyp() */
@@ -425,9 +339,7 @@ addtype(tp)
* and other specifiers (except struct, union, enum, typedef name)
*/
static type_t *
-tdeferr(td, t)
- type_t *td;
- tspec_t t;
+tdeferr(type_t *td, tspec_t t)
{
tspec_t t2;
@@ -479,6 +391,30 @@ tdeferr(td, t)
}
break;
/* LINTED (enumeration values not handled in switch) */
+ case NOTSPEC:
+ case USHORT:
+ case UCHAR:
+ case SCHAR:
+ case CHAR:
+ case FUNC:
+ case ARRAY:
+ case PTR:
+ case ENUM:
+ case UNION:
+ case STRUCT:
+ case VOID:
+ case LDOUBLE:
+ case DOUBLE:
+ case FLOAT:
+ case UQUAD:
+ case QUAD:
+ case ULONG:
+ case UINT:
+ case INT:
+ break;
+
+ case NTSPEC: /* this value unused */
+ break;
}
/* Anything other is not accepted. */
@@ -492,14 +428,12 @@ tdeferr(td, t)
* or enum tag if the typedef name is the first defined for this tag.
*
* If the tag is unnamed, the typdef name is used for identification
- * of this tag in lint2. Although its possible that more then one typedef
+ * of this tag in lint2. Although its possible that more than one typedef
* name is defined for one tag, the first name defined should be unique
* if the tag is unnamed.
*/
static void
-settdsym(tp, sym)
- type_t *tp;
- sym_t *sym;
+settdsym(type_t *tp, sym_t *sym)
{
tspec_t t;
@@ -517,13 +451,13 @@ settdsym(tp, sym)
* (and not the declarator) in the top element of the declaration stack.
* Also detect multiple qualifiers of the same kind.
- * The rememberd qualifier is used by deftyp() to construct the type
+ * The remembered qualifier is used by deftyp() to construct the type
* for all declarators.
*/
void
-addqual(q)
- tqual_t q;
+addqual(tqual_t q)
{
+
if (q == CONST) {
if (dcs->d_const) {
/* duplicate "%s" */
@@ -546,8 +480,7 @@ addqual(q)
* argument declaration lists ...)
*/
void
-pushdecl(sc)
- scl_t sc;
+pushdecl(scl_t sc)
{
dinfo_t *di;
@@ -566,7 +499,7 @@ pushdecl(sc)
* Go back to previous declaration level
*/
void
-popdecl()
+popdecl(void)
{
dinfo_t *di;
@@ -651,7 +584,7 @@ popdecl()
* global declarations/definitions.
*/
void
-setasm()
+setasm(void)
{
dinfo_t *di;
@@ -664,8 +597,9 @@ setasm()
* will be used by the next declaration
*/
void
-clrtyp()
+clrtyp(void)
{
+
dcs->d_atyp = dcs->d_smod = dcs->d_lmod = NOTSPEC;
dcs->d_scl = NOSCL;
dcs->d_type = NULL;
@@ -683,7 +617,7 @@ clrtyp()
* context.
*/
void
-deftyp()
+deftyp(void)
{
tspec_t t, s, l;
type_t *tp;
@@ -799,9 +733,9 @@ deftyp()
* Merge type specifiers (char, ..., long long, signed, unsigned).
*/
static tspec_t
-mrgtspec(t, s)
- tspec_t t, s;
+mrgtspec(tspec_t t, tspec_t s)
{
+
if (s == SIGNED || s == UNSIGN) {
if (t == CHAR) {
t = s == SIGNED ? SCHAR : UCHAR;
@@ -827,17 +761,18 @@ mrgtspec(t, s)
* if name is not NULL.
*/
int
-length(tp, name)
- type_t *tp;
- const char *name;
+length(type_t *tp, const char *name)
{
int elem, elsz;
elem = 1;
- while (tp->t_tspec == ARRAY) {
+ while (tp && tp->t_tspec == ARRAY) {
elem *= tp->t_dim;
tp = tp->t_subt;
}
+ if (tp == NULL)
+ return -1;
+
switch (tp->t_tspec) {
case FUNC:
/* compiler takes size of function */
@@ -870,15 +805,17 @@ length(tp, name)
* Get the alignment of the given Type in bits.
*/
int
-getbound(tp)
- type_t *tp;
+getbound(type_t *tp)
{
int a;
tspec_t t;
- while (tp->t_tspec == ARRAY)
+ while (tp && tp->t_tspec == ARRAY)
tp = tp->t_subt;
+ if (tp == NULL)
+ return -1;
+
if ((t = tp->t_tspec) == STRUCT || t == UNION) {
a = tp->t_str->align;
} else if (t == FUNC) {
@@ -902,8 +839,7 @@ getbound(tp)
* struct/union/enum elements and parameters.
*/
sym_t *
-lnklst(l1, l2)
- sym_t *l1, *l2;
+lnklst(sym_t *l1, sym_t *l2)
{
sym_t *l;
@@ -925,8 +861,7 @@ lnklst(l1, l2)
* - void types other than type of function or pointer
*/
void
-chktyp(sym)
- sym_t *sym;
+chktyp(sym_t *sym)
{
tspec_t to, t;
type_t **tpp, *tp;
@@ -1018,12 +953,12 @@ chktyp(sym)
* Process the declarator of a struct/union element.
*/
sym_t *
-decl1str(dsym)
- sym_t *dsym;
+decl1str(sym_t *dsym)
{
type_t *tp;
tspec_t t;
- int sz, o, len;
+ int sz, len;
+ int o = 0; /* Appease gcc */
scl_t sc;
if ((sc = dsym->s_scl) != MOS && sc != MOU)
@@ -1053,25 +988,38 @@ decl1str(dsym)
*/
if (t == CHAR || t == UCHAR || t == SCHAR ||
t == SHORT || t == USHORT || t == ENUM) {
- if (sflag) {
- /* bit-field type '%s' invalid in ANSI C */
- warning(273, tyname(tp));
- } else if (pflag) {
- /* nonportable bit-field type */
- warning(34);
+ if (bitfieldtype_ok == 0) {
+ if (sflag) {
+ /*
+ * bit-field type '%s' invalid in
+ * ANSI C
+ */
+ warning(273, tyname(tp));
+ } else if (pflag) {
+ /* nonportable bit-field type */
+ warning(34);
+ }
}
} else if (t == INT && dcs->d_smod == NOTSPEC) {
- if (pflag) {
+ if (pflag && bitfieldtype_ok == 0) {
/* nonportable bit-field type */
warning(34);
}
} else if (t != INT && t != UINT) {
- /* illegal bit-field type */
- error(35);
- sz = tp->t_flen;
- dsym->s_type = tp = duptyp(gettyp(t = INT));
- if ((tp->t_flen = sz) > size(t))
- tp->t_flen = size(t);
+ /*
+ * Non-integer types are always illegal for
+ * bitfields, regardless of BITFIELDTYPE.
+ * Integer types not dealt with above are
+ * okay only if BITFIELDTYPE is in effect.
+ */
+ if (bitfieldtype_ok == 0 || isityp(t) == 0) {
+ /* illegal bit-field type */
+ error(35);
+ sz = tp->t_flen;
+ dsym->s_type = tp = duptyp(gettyp(t = INT));
+ if ((tp->t_flen = sz) > size(t))
+ tp->t_flen = size(t);
+ }
}
if ((len = tp->t_flen) < 0 || len > size(t)) {
/* illegal bit-field size */
@@ -1127,6 +1075,12 @@ decl1str(dsym)
chkfdef(dsym, 0);
+ /*
+ * Clear the BITFIELDTYPE indicator after processing each
+ * structure element.
+ */
+ bitfieldtype_ok = 0;
+
return (dsym);
}
@@ -1136,8 +1090,7 @@ decl1str(dsym)
* al contains the required alignment, len the length of a bit-field.
*/
static void
-align(al, len)
- int al, len;
+align(int al, int len)
{
int no;
@@ -1148,7 +1101,7 @@ align(al, len)
*/
if (al > dcs->d_stralign)
dcs->d_stralign = al;
-
+
no = (dcs->d_offset + (al - 1)) & ~(al - 1);
if (len == 0 || dcs->d_offset + len > no)
dcs->d_offset = no;
@@ -1158,16 +1111,15 @@ align(al, len)
* Remember the width of the field in its type structure.
*/
sym_t *
-bitfield(dsym, len)
- sym_t *dsym;
- int len;
+bitfield(sym_t *dsym, int len)
{
+
if (dsym == NULL) {
dsym = getblk(sizeof (sym_t));
dsym->s_name = unnamed;
dsym->s_kind = FMOS;
dsym->s_scl = MOS;
- dsym->s_type = gettyp(INT);
+ dsym->s_type = gettyp(UINT);
dsym->s_blklev = -1;
}
dsym->s_type = duptyp(dsym->s_type);
@@ -1184,14 +1136,14 @@ bitfield(dsym, len)
* will be at the top of the list.
*/
pqinf_t *
-mergepq(p1, p2)
- pqinf_t *p1, *p2;
+mergepq(pqinf_t *p1, pqinf_t *p2)
{
pqinf_t *p;
if (p2->p_pcnt != 0) {
/* left '*' at the end of the list */
- for (p = p2; p->p_nxt != NULL; p = p->p_nxt) ;
+ for (p = p2; p->p_nxt != NULL; p = p->p_nxt)
+ continue;
p->p_nxt = p1;
return (p2);
} else {
@@ -1223,16 +1175,16 @@ mergepq(p1, p2)
* declarator. The new type extension is inserted between both.
*/
sym_t *
-addptr(decl, pi)
- sym_t *decl;
- pqinf_t *pi;
+addptr(sym_t *decl, pqinf_t *pi)
{
type_t **tpp, *tp;
pqinf_t *npi;
tpp = &decl->s_type;
- while (*tpp != dcs->d_type)
+ while (*tpp && *tpp != dcs->d_type)
tpp = &(*tpp)->t_subt;
+ if (*tpp == NULL)
+ return decl;
while (pi != NULL) {
*tpp = tp = getblk(sizeof (type_t));
@@ -1252,15 +1204,15 @@ addptr(decl, pi)
* n is the specified dimension
*/
sym_t *
-addarray(decl, dim, n)
- sym_t *decl;
- int dim, n;
+addarray(sym_t *decl, int dim, int n)
{
type_t **tpp, *tp;
tpp = &decl->s_type;
- while (*tpp != dcs->d_type)
+ while (*tpp && *tpp != dcs->d_type)
tpp = &(*tpp)->t_subt;
+ if (*tpp == NULL)
+ return decl;
*tpp = tp = getblk(sizeof (type_t));
tp->t_tspec = ARRAY;
@@ -1283,8 +1235,7 @@ addarray(decl, dim, n)
}
sym_t *
-addfunc(decl, args)
- sym_t *decl, *args;
+addfunc(sym_t *decl, sym_t *args)
{
type_t **tpp, *tp;
@@ -1314,8 +1265,10 @@ addfunc(decl, args)
}
tpp = &decl->s_type;
- while (*tpp != dcs->d_nxt->d_type)
+ while (*tpp && *tpp != dcs->d_nxt->d_type)
tpp = &(*tpp)->t_subt;
+ if (*tpp == NULL)
+ return decl;
*tpp = tp = getblk(sizeof (type_t));
tp->t_tspec = FUNC;
@@ -1332,8 +1285,7 @@ addfunc(decl, args)
*/
/* ARGSUSED */
static sym_t *
-nsfunc(decl, args)
- sym_t *decl, *args;
+nsfunc(sym_t *decl, sym_t *args)
{
sym_t *arg, *sym;
scl_t sc;
@@ -1371,9 +1323,9 @@ nsfunc(decl, args)
* Called for old style function declarations.
*/
static void
-osfunc(decl, args)
- sym_t *decl, *args;
+osfunc(sym_t *decl, sym_t *args)
{
+
/*
* Remember list of params only if this is really seams to be
* a function definition.
@@ -1382,7 +1334,7 @@ osfunc(decl, args)
decl->s_type == dcs->d_nxt->d_type) {
/*
* We assume that this becomes a function definition. If
- * we are wrong, its corrected in chkfdef().
+ * we are wrong, its corrected in chkfdef().
*/
if (args != NULL) {
decl->s_osdef = 1;
@@ -1401,10 +1353,9 @@ osfunc(decl, args)
* error message.
*/
void
-chkfdef(sym, msg)
- sym_t *sym;
- int msg;
+chkfdef(sym_t *sym, int msg)
{
+
if (sym->s_osdef) {
if (msg) {
/* incomplete or misplaced function definition */
@@ -1423,10 +1374,9 @@ chkfdef(sym, msg)
* s_def and s_reg are valid after dname().
*/
sym_t *
-dname(sym)
- sym_t *sym;
+dname(sym_t *sym)
{
- scl_t sc;
+ scl_t sc = NOSCL;
if (sym->s_scl == NOSCL) {
dcs->d_rdcsym = NULL;
@@ -1489,7 +1439,7 @@ dname(sym)
* XXX somewhat ugly because we dont know whether
* this is AUTO or EXTERN (functions). If we are
* wrong it must be corrected in decl1loc(), where
- * we have the neccessary type information.
+ * we have the necessary type information.
*/
sc = AUTO;
sym->s_def = DEF;
@@ -1522,9 +1472,9 @@ dname(sym)
* definition.
*/
sym_t *
-iname(sym)
- sym_t *sym;
+iname(sym_t *sym)
{
+
if (sym->s_scl != NOSCL) {
if (blklev == sym->s_blklev) {
/* redeclaration of formal parameter %s */
@@ -1551,12 +1501,9 @@ iname(sym)
* semi is 1 if the following token is T_SEMI
*/
type_t *
-mktag(tag, kind, decl, semi)
- sym_t *tag;
- tspec_t kind;
- int decl, semi;
+mktag(sym_t *tag, tspec_t kind, int decl, int semi)
{
- scl_t scl;
+ scl_t scl = NOSCL;
type_t *tp;
if (kind == STRUCT) {
@@ -1590,7 +1537,7 @@ mktag(tag, kind, decl, semi)
} else {
tag = getblk(sizeof (sym_t));
tag->s_name = unnamed;
- STRUCT_ASSIGN(tag->s_dpos, curr_pos);
+ UNIQUE_CURR_POS(tag->s_dpos);
tag->s_kind = FTAG;
tag->s_scl = scl;
tag->s_blklev = -1;
@@ -1622,11 +1569,9 @@ mktag(tag, kind, decl, semi)
* semi is 1 if T_SEMI follows
*/
static sym_t *
-newtag(tag, scl, decl, semi)
- sym_t *tag;
- scl_t scl;
- int decl, semi;
+newtag(sym_t *tag, scl_t scl, int decl, int semi)
{
+
if (tag->s_blklev < blklev) {
if (semi) {
/* "struct a;" */
@@ -1641,7 +1586,7 @@ newtag(tag, scl, decl, semi)
}
dcs->d_nxt->d_nedecl = 1;
} else if (decl) {
- /* "struct a { ..." */
+ /* "struct a { ... } " */
if (hflag)
/* redefinition hides earlier one: %s */
warning(43, tag->s_name);
@@ -1677,8 +1622,7 @@ newtag(tag, scl, decl, semi)
}
const char *
-scltoa(sc)
- scl_t sc;
+scltoa(scl_t sc)
{
const char *s;
@@ -1701,9 +1645,7 @@ scltoa(sc)
* tp points to the type of the, tag, fmem to the list of members/enums.
*/
type_t *
-compltag(tp, fmem)
- type_t *tp;
- sym_t *fmem;
+compltag(type_t *tp, sym_t *fmem)
{
tspec_t t;
str_t *sp;
@@ -1745,13 +1687,12 @@ compltag(tp, fmem)
*
* sym points to the enumerator
* val is the value of the enumerator
- * impl is 1 if the the value of the enumerator was not explicit specified.
+ * impl is 1 if the value of the enumerator was not explicit specified.
*/
sym_t *
-ename(sym, val, impl)
- sym_t *sym;
- int val, impl;
+ename(sym_t *sym, int val, int impl)
{
+
if (sym->s_scl) {
if (sym->s_blklev == blklev) {
/* no hflag, because this is illegal!!! */
@@ -1792,9 +1733,7 @@ ename(sym, val, impl)
* Process a single external declarator.
*/
void
-decl1ext(dsym, initflg)
- sym_t *dsym;
- int initflg;
+decl1ext(sym_t *dsym, int initflg)
{
int warn, rval, redec;
sym_t *rdsym;
@@ -1850,7 +1789,7 @@ decl1ext(dsym, initflg)
}
if (!redec && !isredec(dsym, (warn = 0, &warn))) {
-
+
if (warn) {
/* redeclaration of %s */
(*(sflag ? error : warning))(27, dsym->s_name);
@@ -1896,7 +1835,7 @@ decl1ext(dsym, initflg)
compltyp(dsym, rdsym);
}
-
+
rmsym(rdsym);
}
@@ -1913,9 +1852,9 @@ decl1ext(dsym, initflg)
* the same symbol.
*/
void
-cpuinfo(sym, rdsym)
- sym_t *sym, *rdsym;
+cpuinfo(sym_t *sym, sym_t *rdsym)
{
+
sym->s_spos = rdsym->s_spos;
sym->s_upos = rdsym->s_upos;
sym->s_set = rdsym->s_set;
@@ -1928,9 +1867,7 @@ cpuinfo(sym, rdsym)
* a warning.
*/
int
-isredec(dsym, warn)
- sym_t *dsym;
- int *warn;
+isredec(sym_t *dsym, int *warn)
{
sym_t *rsym;
@@ -2003,15 +1940,13 @@ isredec(dsym, warn)
* Checks if two types are compatible. Returns 0 if not, otherwise 1.
*
* ignqual ignore qualifiers of type; used for function params
- * promot promote left type; used for comparision of params of
+ * promot promote left type; used for comparison of params of
* old style function definitions with params of prototypes.
* *warn set to 1 if an old style function declaration is not
* compatible with a prototype
*/
int
-eqtype(tp1, tp2, ignqual, promot, warn)
- type_t *tp1, *tp2;
- int ignqual, promot, *warn;
+eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *warn)
{
tspec_t t;
@@ -2077,9 +2012,7 @@ eqtype(tp1, tp2, ignqual, promot, warn)
* Compares the parameter types of two prototypes.
*/
static int
-eqargs(tp1, tp2, warn)
- type_t *tp1, *tp2;
- int *warn;
+eqargs(type_t *tp1, type_t *tp2, int *warn)
{
sym_t *a1, *a2;
@@ -2113,9 +2046,7 @@ eqargs(tp1, tp2, warn)
* is applied on it
*/
static int
-mnoarg(tp, warn)
- type_t *tp;
- int *warn;
+mnoarg(type_t *tp, int *warn)
{
sym_t *arg;
tspec_t t;
@@ -2140,8 +2071,7 @@ mnoarg(tp, warn)
* a previous old style function definition.
*/
static int
-chkosdef(rdsym, dsym)
- sym_t *rdsym, *dsym;
+chkosdef(sym_t *rdsym, sym_t *dsym)
{
sym_t *args, *pargs, *arg, *parg;
int narg, nparg, n;
@@ -2202,8 +2132,7 @@ chkosdef(rdsym, dsym)
* be duplicated.
*/
void
-compltyp(dsym, ssym)
- sym_t *dsym, *ssym;
+compltyp(sym_t *dsym, sym_t *ssym)
{
type_t **dstp, *src;
type_t *dst;
@@ -2237,9 +2166,7 @@ compltyp(dsym, ssym)
* Completes the declaration of a single argument.
*/
sym_t *
-decl1arg(sym, initflg)
- sym_t *sym;
- int initflg;
+decl1arg(sym_t *sym, int initflg)
{
tspec_t t;
@@ -2303,7 +2230,7 @@ decl1arg(sym, initflg)
* prototype.
*/
void
-cluparg()
+cluparg(void)
{
sym_t *args, *arg, *pargs, *parg;
int narg, nparg, n, msg;
@@ -2417,7 +2344,7 @@ cluparg()
/* from now the prototype is valid */
funcsym->s_osdef = 0;
funcsym->s_args = NULL;
-
+
}
}
@@ -2428,8 +2355,7 @@ cluparg()
* Returns 1 if the position of the previous declaration should be reported.
*/
static int
-chkptdecl(arg, parg)
- sym_t *arg, *parg;
+chkptdecl(sym_t *arg, sym_t *parg)
{
type_t *tp, *ptp;
int warn, msg;
@@ -2462,10 +2388,9 @@ chkptdecl(arg, parg)
* Completes a single local declaration/definition.
*/
void
-decl1loc(dsym, initflg)
- sym_t *dsym;
- int initflg;
+decl1loc(sym_t *dsym, int initflg)
{
+
/* Correct a mistake done in dname(). */
if (dsym->s_type->t_tspec == FUNC) {
dsym->s_def = DECL;
@@ -2570,7 +2495,7 @@ decl1loc(dsym, initflg)
if (hflag)
/* declaration hides earlier one: %s */
warning(95, dsym->s_name);
-
+
}
if (dcs->d_rdcsym->s_blklev == blklev) {
@@ -2604,8 +2529,7 @@ decl1loc(dsym, initflg)
* Processes (re)declarations of external Symbols inside blocks.
*/
static void
-ledecl(dsym)
- sym_t *dsym;
+ledecl(sym_t *dsym)
{
int eqt, warn;
sym_t *esym;
@@ -2660,8 +2584,7 @@ ledecl(dsym)
* detected.
*/
static int
-chkinit(sym)
- sym_t *sym;
+chkinit(sym_t *sym)
{
int err;
@@ -2692,7 +2615,7 @@ chkinit(sym)
* Create a symbole for an abstract declaration.
*/
sym_t *
-aname()
+aname(void)
{
sym_t *sym;
@@ -2720,8 +2643,9 @@ aname()
* Removes anything which has nothing to do on global level.
*/
void
-globclup()
+globclup(void)
{
+
while (dcs->d_nxt != NULL)
popdecl();
@@ -2740,9 +2664,9 @@ globclup()
* Process an abstract type declaration
*/
sym_t *
-decl1abs(sym)
- sym_t *sym;
+decl1abs(sym_t *sym)
{
+
chkfdef(sym, 1);
chktyp(sym);
return (sym);
@@ -2752,9 +2676,9 @@ decl1abs(sym)
* Checks size after declarations of variables and their initialisation.
*/
void
-chksz(dsym)
- sym_t *dsym;
+chksz(sym_t *dsym)
{
+
/*
* check size only for symbols which are defined and no function and
* not typedef name
@@ -2781,12 +2705,12 @@ chksz(dsym)
* Mark an object as set if it is not already
*/
void
-setsflg(sym)
- sym_t *sym;
+setsflg(sym_t *sym)
{
+
if (!sym->s_set) {
sym->s_set = 1;
- STRUCT_ASSIGN(sym->s_spos, curr_pos);
+ UNIQUE_CURR_POS(sym->s_spos);
}
}
@@ -2794,13 +2718,12 @@ setsflg(sym)
* Mark an object as used if it is not already
*/
void
-setuflg(sym, fcall, szof)
- sym_t *sym;
- int fcall, szof;
+setuflg(sym_t *sym, int fcall, int szof)
{
+
if (!sym->s_used) {
sym->s_used = 1;
- STRUCT_ASSIGN(sym->s_upos, curr_pos);
+ UNIQUE_CURR_POS(sym->s_upos);
}
/*
* for function calls another record is written
@@ -2818,8 +2741,7 @@ setuflg(sym, fcall, szof)
* with s_dlnxt) if these are not used or only set.
*/
void
-chkusage(di)
- dinfo_t *di;
+chkusage(dinfo_t *di)
{
sym_t *sym;
int mknowarn;
@@ -2839,9 +2761,7 @@ chkusage(di)
* only set.
*/
void
-chkusg1(novar, sym)
- int novar;
- sym_t *sym;
+chkusg1(int novar, sym_t *sym)
{
pos_t cpos;
@@ -2866,10 +2786,9 @@ chkusg1(novar, sym)
}
static void
-chkausg(novar, arg)
- int novar;
- sym_t *arg;
+chkausg(int novar, sym_t *arg)
{
+
if (!arg->s_set)
lerror("chkausg() 1");
@@ -2884,9 +2803,7 @@ chkausg(novar, arg)
}
static void
-chkvusg(novar, sym)
- int novar;
- sym_t *sym;
+chkvusg(int novar, sym_t *sym)
{
scl_t sc;
sym_t *xsym;
@@ -2953,9 +2870,9 @@ chkvusg(novar, sym)
}
static void
-chklusg(lab)
- sym_t *lab;
+chklusg(sym_t *lab)
{
+
if (blklev != 1 || lab->s_blklev != 1)
lerror("chklusg() 1");
@@ -2971,9 +2888,9 @@ chklusg(lab)
}
static void
-chktusg(sym)
- sym_t *sym;
+chktusg(sym_t *sym)
{
+
if (!incompl(sym->s_type))
return;
@@ -3009,7 +2926,7 @@ chktusg(sym)
* - static symbols which are never used
*/
void
-chkglsyms()
+chkglsyms(void)
{
sym_t *sym;
pos_t cpos;
@@ -3036,12 +2953,12 @@ chkglsyms()
}
static void
-chkglvar(sym)
- sym_t *sym;
+chkglvar(sym_t *sym)
{
+
if (sym->s_scl == TYPEDEF || sym->s_scl == ENUMCON)
return;
-
+
if (sym->s_scl != EXTERN && sym->s_scl != STATIC)
lerror("chkglvar() 1");
@@ -3083,13 +3000,13 @@ chkglvar(sym)
}
static void
-glchksz(sym)
- sym_t *sym;
+glchksz(sym_t *sym)
{
+
if (sym->s_def == TDEF) {
if (sym->s_type->t_tspec == FUNC)
/*
- * this can happen if an syntax error occured
+ * this can happen if an syntax error occurred
* after a function declaration
*/
return;
@@ -3110,9 +3027,7 @@ glchksz(sym)
* Prints information about location of previous definition/declaration.
*/
void
-prevdecl(msg, psym)
- int msg;
- sym_t *psym;
+prevdecl(int msg, sym_t *psym)
{
pos_t cpos;
diff --git a/usr.bin/xlint/lint1/emit1.c b/usr.bin/xlint/lint1/emit1.c
index ee2434e..fc47a84 100644
--- a/usr.bin/xlint/lint1/emit1.c
+++ b/usr.bin/xlint/lint1/emit1.c
@@ -1,6 +1,7 @@
-/* $NetBSD: emit1.c,v 1.4 1995/10/02 17:21:28 jpo Exp $ */
+/* $NetBSD: emit1.c,v 1.11 2002/01/31 19:36:54 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -31,16 +32,17 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: emit1.c,v 1.4 1995/10/02 17:21:28 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: emit1.c,v 1.11 2002/01/31 19:36:54 tv Exp $");
#endif
#include <ctype.h>
#include "lint1.h"
-static void outtt __P((sym_t *, sym_t *));
-static void outfstrg __P((strg_t *));
+static void outtt(sym_t *, sym_t *);
+static void outfstrg(strg_t *);
/*
* Write type into the output buffer.
@@ -82,8 +84,7 @@ static void outfstrg __P((strg_t *));
* and 'v' (for volatile)
*/
void
-outtype(tp)
- type_t *tp;
+outtype(type_t *tp)
{
int t, s, na;
sym_t *arg;
@@ -153,8 +154,7 @@ outtype(tp)
* it uses its own output buffer for conversion
*/
const char *
-ttos(tp)
- type_t *tp;
+ttos(type_t *tp)
{
static ob_t tob;
ob_t tmp;
@@ -184,9 +184,12 @@ ttos(tp)
* refers to this tag, this typename is written
*/
static void
-outtt(tag, tdef)
- sym_t *tag, *tdef;
+outtt(sym_t *tag, sym_t *tdef)
{
+
+ /*
+ * 0 is no longer used.
+ */
if (tag->s_name != unnamed) {
outint(1);
outname(tag->s_name);
@@ -194,7 +197,12 @@ outtt(tag, tdef)
outint(2);
outname(tdef->s_name);
} else {
- outint(0);
+ outint(3);
+ outint(tag->s_dpos.p_line);
+ outchar('.');
+ outint(getfnid(tag->s_dpos.p_file));
+ outchar('.');
+ outint(tag->s_dpos.p_uniq);
}
}
@@ -206,11 +214,9 @@ outtt(tag, tdef)
* not here
*/
void
-outsym(sym, sc, def)
- sym_t *sym;
- scl_t sc;
- def_t def;
+outsym(sym_t *sym, scl_t sc, def_t def)
{
+
/*
* Static function declarations must also be written to the output
* file. Compatibility of function declarations (for both static
@@ -266,6 +272,12 @@ outsym(sym, sc, def)
/* name of the symbol */
outname(sym->s_name);
+ /* renamed name of symbol, if necessary */
+ if (sym->s_rename) {
+ outchar('r');
+ outname(sym->s_rename);
+ }
+
/* type of the symbol */
outtype(sym->s_type);
}
@@ -277,10 +289,7 @@ outsym(sym, sc, def)
* they are called with proper argument types
*/
void
-outfdef(fsym, posp, rval, osdef, args)
- sym_t *fsym, *args;
- pos_t *posp;
- int rval, osdef;
+outfdef(sym_t *fsym, pos_t *posp, int rval, int osdef, sym_t *args)
{
int narg;
sym_t *arg;
@@ -352,6 +361,12 @@ outfdef(fsym, posp, rval, osdef, args)
/* name of function */
outname(fsym->s_name);
+ /* renamed name of function, if necessary */
+ if (fsym->s_rename) {
+ outchar('r');
+ outname(fsym->s_rename);
+ }
+
/* argument types and return value */
if (osdef) {
narg = 0;
@@ -376,13 +391,11 @@ outfdef(fsym, posp, rval, osdef, args)
* (casted to void)
*/
void
-outcall(tn, rvused, rvdisc)
- tnode_t *tn;
- int rvused, rvdisc;
+outcall(tnode_t *tn, int rvused, int rvdisc)
{
tnode_t *args, *arg;
int narg, n, i;
- quad_t q;
+ int64_t q;
tspec_t t;
/* reset buffer */
@@ -410,7 +423,8 @@ outcall(tn, rvused, rvdisc)
/* informations about arguments */
for (n = 1; n <= narg; n++) {
/* the last argument is the top one in the tree */
- for (i = narg, arg = args; i > n; i--, arg = arg->tn_right) ;
+ for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
+ continue;
arg = arg->tn_left;
if (arg->tn_op == CON) {
if (isityp(t = arg->tn_type->t_tspec)) {
@@ -451,7 +465,8 @@ outcall(tn, rvused, rvdisc)
outint(narg);
for (n = 1; n <= narg; n++) {
/* the last argument is the top one in the tree */
- for (i = narg, arg = args; i > n; i--, arg = arg->tn_right) ;
+ for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
+ continue;
outtype(arg->tn_left->tn_type);
}
/* expected type of return value */
@@ -463,8 +478,7 @@ outcall(tn, rvused, rvdisc)
* writes them, enclosed in "" and qouted if necessary, to the output buffer
*/
static void
-outfstrg(strg)
- strg_t *strg;
+outfstrg(strg_t *strg)
{
int c, oc, first;
u_char *cp;
@@ -563,8 +577,7 @@ outfstrg(strg)
* writes a record if sym was used
*/
void
-outusg(sym)
- sym_t *sym;
+outusg(sym_t *sym)
{
/* reset buffer */
outclr();
diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c
index 32c80c4..ffbc1bc 100644
--- a/usr.bin/xlint/lint1/err.c
+++ b/usr.bin/xlint/lint1/err.c
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.8 1995/10/02 17:37:00 jpo Exp $ */
+/* $NetBSD: err.c,v 1.16 2001/12/13 23:56:00 augustss Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,28 +31,27 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: err.c,v 1.8 1995/10/02 17:37:00 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: err.c,v 1.16 2001/12/13 23:56:00 augustss Exp $");
#endif
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "lint1.h"
+
/* number of errors found */
int nerr;
/* number of syntax errors */
int sytxerr;
-#include <stdlib.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "lint1.h"
-static const char *basename __P((const char *));
-static void verror __P((int, va_list));
-static void vwarning __P((int, va_list));
+static const char *basename(const char *);
+static void verror(int, va_list);
+static void vwarning(int, va_list);
const char *msgs[] = {
@@ -218,7 +217,7 @@ const char *msgs[] = {
"assignment in conditional context", /* 159 */
"operator '==' found where '=' was expected", /* 160 */
"constant in conditional context", /* 161 */
- "comparision of %s with %s, op %s", /* 162 */
+ "comparison of %s with %s, op %s", /* 162 */
"a cast does not yield an lvalue", /* 163 */
"assignment of negative constant to unsigned type", /* 164 */
"constant truncated by assignment", /* 165 */
@@ -286,7 +285,7 @@ const char *msgs[] = {
"const object %s should have initializer", /* 227 */
"function cannot return const or volatile object", /* 228 */
"questionable conversion of function pointer", /* 229 */
- "nonportable character comparision, op %s", /* 230 */
+ "nonportable character comparison, op %s", /* 230 */
"argument %s unused in function %s", /* 231 */
"label %s unused in function %s", /* 232 */
"struct %s never defined", /* 233 */
@@ -299,7 +298,7 @@ const char *msgs[] = {
"assignment of different structures", /* 240 */
"dubious operation on enum, op %s", /* 241 */
"combination of '%s' and '%s', op %s", /* 242 */
- "dubious comparision of enums, op %s", /* 243 */
+ "dubious comparison of enums, op %s", /* 243 */
"illegal structure pointer combination", /* 244 */
"illegal structure pointer combination, op %s", /* 245 */
"dubious conversion of enum to '%s'", /* 246 */
@@ -330,7 +329,7 @@ const char *msgs[] = {
"switch expression must be of type `int' in traditional C", /* 271 */
"empty translation unit", /* 272 */
"bit-field type '%s' invalid in ANSI C", /* 273 */
- "ANSI C forbids comparision of %s with %s", /* 274 */
+ "ANSI C forbids comparison of %s with %s", /* 274 */
"cast discards 'const' from pointer target type", /* 275 */
"", /* 276 */
"initialisation of '%s' with '%s'", /* 277 */
@@ -366,15 +365,29 @@ const char *msgs[] = {
"static variable %s set but not used", /* 307 */
"", /* 308 */
"extra bits set to 0 in conversion of '%s' to '%s', op %s", /* 309 */
+ "symbol renaming can't be used on function arguments", /* 310 */
+ "symbol renaming can't be used on automatic variables", /* 311 */
+ "%s C does not support // comments", /* 312 */
};
/*
+ * print a list of the messages with their ids
+ */
+void
+msglist(void)
+{
+ int i;
+
+ for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
+ printf("%d\t%s\n", i, msgs[i]);
+}
+
+/*
* If Fflag is not set basename() returns a pointer to the last
* component of the path, otherwise it returns the argument.
*/
static const char *
-basename(path)
- const char *path;
+basename(const char *path)
{
const char *cp, *cp1, *cp2;
@@ -392,26 +405,28 @@ basename(path)
}
static void
-verror(n, ap)
- int n;
- va_list ap;
+verror( int n, va_list ap)
{
const char *fn;
+ if (ERR_ISSET(n, &msgset))
+ return;
+
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
- (void)printf("\n");
+ (void)printf(" [%d]\n", n);
nerr++;
}
static void
-vwarning(n, ap)
- int n;
- va_list ap;
+vwarning( int n, va_list ap)
{
const char *fn;
+ if (ERR_ISSET(n, &msgset))
+ return;
+
if (nowarn)
/* this warning is suppressed by a LINTED comment */
return;
@@ -419,46 +434,28 @@ vwarning(n, ap)
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
- (void)printf("\n");
+ (void)printf(" [%d]\n", n);
+ if (wflag)
+ nerr++;
}
void
-#ifdef __STDC__
error(int n, ...)
-#else
-error(n, va_alist)
- int n;
- va_dcl
-#endif
{
va_list ap;
-#ifdef __STDC__
va_start(ap, n);
-#else
- va_start(ap);
-#endif
verror(n, ap);
va_end(ap);
}
void
-#ifdef __STDC__
lerror(const char *msg, ...)
-#else
-lerror(msg, va_alist)
- const char *msg;
- va_dcl
-#endif
{
va_list ap;
const char *fn;
-#ifdef __STDC__
va_start(ap, msg);
-#else
- va_start(ap);
-#endif
fn = basename(curr_pos.p_file);
(void)fprintf(stderr, "%s(%d): lint error: ", fn, curr_pos.p_line);
(void)vfprintf(stderr, msg, ap);
@@ -468,66 +465,39 @@ lerror(msg, va_alist)
}
void
-#ifdef __STDC__
warning(int n, ...)
-#else
-warning(n, va_alist)
- int n;
- va_dcl
-#endif
{
va_list ap;
-#ifdef __STDC__
va_start(ap, n);
-#else
- va_start(ap);
-#endif
vwarning(n, ap);
va_end(ap);
}
void
-#ifdef __STDC__
message(int n, ...)
-#else
-message(n, va_alist)
- int n;
- va_dcl
-#endif
{
va_list ap;
const char *fn;
-#ifdef __STDC__
+ if (ERR_ISSET(n, &msgset))
+ return;
+
va_start(ap, n);
-#else
- va_start(ap);
-#endif
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
- (void)printf("\n");
+ (void)printf(" [%d]\n", n);
va_end(ap);
}
int
-#ifdef __STDC__
gnuism(int n, ...)
-#else
-gnuism(n, va_alist)
- int n;
- va_dcl
-#endif
{
va_list ap;
int msg;
-#ifdef __STDC__
va_start(ap, n);
-#else
- va_start(ap);
-#endif
if (sflag && !gflag) {
verror(n, ap);
msg = 1;
diff --git a/usr.bin/xlint/lint1/externs1.h b/usr.bin/xlint/lint1/externs1.h
index e9923c7..765c1ef 100644
--- a/usr.bin/xlint/lint1/externs1.h
+++ b/usr.bin/xlint/lint1/externs1.h
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.7 1995/10/02 17:31:39 jpo Exp $ */
+/* $NetBSD: externs1.h,v 1.13 2002/01/18 21:01:39 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -42,16 +42,16 @@ extern int eflag;
extern int Fflag;
extern int gflag;
extern int hflag;
-extern int pflag;
extern int rflag;
extern int sflag;
extern int tflag;
extern int uflag;
extern int vflag;
extern int yflag;
+extern int wflag;
extern int zflag;
-extern void norecover __P((void));
+extern void norecover(void);
/*
* cgram.y
@@ -60,8 +60,8 @@ extern int blklev;
extern int mblklev;
extern int yydebug;
-extern int yyerror __P((char *));
-extern int yyparse __P((void));
+extern int yyerror(char *);
+extern int yyparse(void);
/*
* scan.l
@@ -70,41 +70,41 @@ extern pos_t curr_pos;
extern pos_t csrc_pos;
extern symt_t symtyp;
extern FILE *yyin;
-extern u_quad_t qbmasks[], qlmasks[], qumasks[];
+extern uint64_t qbmasks[], qlmasks[], qumasks[];
-extern void initscan __P((void));
-extern int sign __P((quad_t, tspec_t, int));
-extern int msb __P((quad_t, tspec_t, int));
-extern quad_t xsign __P((quad_t, tspec_t, int));
-extern void clrwflgs __P((void));
-extern sym_t *getsym __P((sbuf_t *));
-extern void cleanup __P((void));
-extern sym_t *pushdown __P((sym_t *));
-extern void rmsym __P((sym_t *));
-extern void rmsyms __P((sym_t *));
-extern void inssym __P((int, sym_t *));
-extern void freeyyv __P((void *, int));
-extern int yylex __P((void));
+extern void initscan(void);
+extern int sign(int64_t, tspec_t, int);
+extern int msb(int64_t, tspec_t, int);
+extern int64_t xsign(int64_t, tspec_t, int);
+extern void clrwflgs(void);
+extern sym_t *getsym(sbuf_t *);
+extern void cleanup(void);
+extern sym_t *pushdown(sym_t *);
+extern void rmsym(sym_t *);
+extern void rmsyms(sym_t *);
+extern void inssym(int, sym_t *);
+extern void freeyyv(void *, int);
+extern int yylex(void);
/*
* mem1.c
*/
-extern const char *fnalloc __P((const char *));
-extern const char *fnnalloc __P((const char *, size_t));
-extern int getfnid __P((const char *));
+extern const char *fnalloc(const char *);
+extern const char *fnnalloc(const char *, size_t);
+extern int getfnid(const char *);
-extern void initmem __P((void));
+extern void initmem(void);
-extern void *getblk __P((size_t));
-extern void *getlblk __P((int, size_t));
-extern void freeblk __P((void));
-extern void freelblk __P((int));
+extern void *getblk(size_t);
+extern void *getlblk(int, size_t);
+extern void freeblk(void);
+extern void freelblk(int);
-extern void *tgetblk __P((size_t));
-extern tnode_t *getnode __P((void));
-extern void tfreeblk __P((void));
-extern struct mbl *tsave __P((void));
-extern void trestor __P((struct mbl *));
+extern void *tgetblk(size_t);
+extern tnode_t *getnode(void);
+extern void tfreeblk(void);
+extern struct mbl *tsave(void);
+extern void trestor(struct mbl *);
/*
* err.c
@@ -113,11 +113,13 @@ extern int nerr;
extern int sytxerr;
extern const char *msgs[];
-extern void error __P((int, ...));
-extern void warning __P((int, ...));
-extern void message __P((int, ...));
-extern int gnuism __P((int, ...));
-extern void lerror __P((const char *, ...));
+extern void msglist(void);
+extern void error(int, ...);
+extern void warning(int, ...);
+extern void message(int, ...);
+extern int gnuism(int, ...);
+extern void lerror(const char *, ...)
+ __attribute__((__noreturn__,__format__(__printf__, 1, 2)));
/*
* decl.c
@@ -126,82 +128,82 @@ extern dinfo_t *dcs;
extern const char *unnamed;
extern int enumval;
-extern void initdecl __P((void));
-extern type_t *gettyp __P((tspec_t));
-extern type_t *duptyp __P((const type_t *));
-extern type_t *tduptyp __P((const type_t *));
-extern int incompl __P((type_t *));
-extern void setcompl __P((type_t *, int));
-extern void addscl __P((scl_t));
-extern void addtype __P((type_t *));
-extern void addqual __P((tqual_t));
-extern void pushdecl __P((scl_t));
-extern void popdecl __P((void));
-extern void setasm __P((void));
-extern void clrtyp __P((void));
-extern void deftyp __P((void));
-extern int length __P((type_t *, const char *));
-extern int getbound __P((type_t *));
-extern sym_t *lnklst __P((sym_t *, sym_t *));
-extern void chktyp __P((sym_t *));
-extern sym_t *decl1str __P((sym_t *));
-extern sym_t *bitfield __P((sym_t *, int));
-extern pqinf_t *mergepq __P((pqinf_t *, pqinf_t *));
-extern sym_t *addptr __P((sym_t *, pqinf_t *));
-extern sym_t *addarray __P((sym_t *, int, int));
-extern sym_t *addfunc __P((sym_t *, sym_t *));
-extern void chkfdef __P((sym_t *, int));
-extern sym_t *dname __P((sym_t *));
-extern sym_t *iname __P((sym_t *));
-extern type_t *mktag __P((sym_t *, tspec_t, int, int));
-extern const char *scltoa __P((scl_t));
-extern type_t *compltag __P((type_t *, sym_t *));
-extern sym_t *ename __P((sym_t *, int, int));
-extern void decl1ext __P((sym_t *, int));
-extern void cpuinfo __P((sym_t *, sym_t *));
-extern int isredec __P((sym_t *, int *));
-extern int eqtype __P((type_t *, type_t *, int, int, int *));
-extern void compltyp __P((sym_t *, sym_t *));
-extern sym_t *decl1arg __P((sym_t *, int));
-extern void cluparg __P((void));
-extern void decl1loc __P((sym_t *, int));
-extern sym_t *aname __P((void));
-extern void globclup __P((void));
-extern sym_t *decl1abs __P((sym_t *));
-extern void chksz __P((sym_t *));
-extern void setsflg __P((sym_t *));
-extern void setuflg __P((sym_t *, int, int));
-extern void chkusage __P((dinfo_t *));
-extern void chkusg1 __P((int, sym_t *));
-extern void chkglsyms __P((void));
-extern void prevdecl __P((int, sym_t *));
+extern void initdecl(void);
+extern type_t *gettyp(tspec_t);
+extern type_t *duptyp(const type_t *);
+extern type_t *tduptyp(const type_t *);
+extern int incompl(type_t *);
+extern void setcompl(type_t *, int);
+extern void addscl(scl_t);
+extern void addtype(type_t *);
+extern void addqual(tqual_t);
+extern void pushdecl(scl_t);
+extern void popdecl(void);
+extern void setasm(void);
+extern void clrtyp(void);
+extern void deftyp(void);
+extern int length(type_t *, const char *);
+extern int getbound(type_t *);
+extern sym_t *lnklst(sym_t *, sym_t *);
+extern void chktyp(sym_t *);
+extern sym_t *decl1str(sym_t *);
+extern sym_t *bitfield(sym_t *, int);
+extern pqinf_t *mergepq(pqinf_t *, pqinf_t *);
+extern sym_t *addptr(sym_t *, pqinf_t *);
+extern sym_t *addarray(sym_t *, int, int);
+extern sym_t *addfunc(sym_t *, sym_t *);
+extern void chkfdef(sym_t *, int);
+extern sym_t *dname(sym_t *);
+extern sym_t *iname(sym_t *);
+extern type_t *mktag(sym_t *, tspec_t, int, int);
+extern const char *scltoa(scl_t);
+extern type_t *compltag(type_t *, sym_t *);
+extern sym_t *ename(sym_t *, int, int);
+extern void decl1ext(sym_t *, int);
+extern void cpuinfo(sym_t *, sym_t *);
+extern int isredec(sym_t *, int *);
+extern int eqtype(type_t *, type_t *, int, int, int *);
+extern void compltyp(sym_t *, sym_t *);
+extern sym_t *decl1arg(sym_t *, int);
+extern void cluparg(void);
+extern void decl1loc(sym_t *, int);
+extern sym_t *aname(void);
+extern void globclup(void);
+extern sym_t *decl1abs(sym_t *);
+extern void chksz(sym_t *);
+extern void setsflg(sym_t *);
+extern void setuflg(sym_t *, int, int);
+extern void chkusage(dinfo_t *);
+extern void chkusg1(int, sym_t *);
+extern void chkglsyms(void);
+extern void prevdecl(int, sym_t *);
/*
* tree.c
*/
-extern void initmtab __P((void));
-extern type_t *incref __P((type_t *, tspec_t));
-extern type_t *tincref __P((type_t *, tspec_t));
-extern tnode_t *getcnode __P((type_t *, val_t *));
-extern tnode_t *getnnode __P((sym_t *, int));
-extern tnode_t *getsnode __P((strg_t *));
-extern sym_t *strmemb __P((tnode_t *, op_t, sym_t *));
-extern tnode_t *build __P((op_t, tnode_t *, tnode_t *));
-extern tnode_t *cconv __P((tnode_t *));
-extern int typeok __P((op_t, int, tnode_t *, tnode_t *));
-extern tnode_t *promote __P((op_t, int, tnode_t *));
-extern tnode_t *convert __P((op_t, int, type_t *, tnode_t *));
-extern void cvtcon __P((op_t, int, type_t *, val_t *, val_t *));
-extern const char *tyname __P((type_t *));
-extern tnode_t *bldszof __P((type_t *));
-extern tnode_t *cast __P((tnode_t *, type_t *));
-extern tnode_t *funcarg __P((tnode_t *, tnode_t *));
-extern tnode_t *funccall __P((tnode_t *, tnode_t *));
-extern val_t *constant __P((tnode_t *));
-extern void expr __P((tnode_t *, int, int));
-extern void chkmisc __P((tnode_t *, int, int, int, int, int, int));
-extern int conaddr __P((tnode_t *, sym_t **, ptrdiff_t *));
-extern strg_t *catstrg __P((strg_t *, strg_t *));
+extern void initmtab(void);
+extern type_t *incref(type_t *, tspec_t);
+extern type_t *tincref(type_t *, tspec_t);
+extern tnode_t *getcnode(type_t *, val_t *);
+extern tnode_t *getnnode(sym_t *, int);
+extern tnode_t *getsnode(strg_t *);
+extern sym_t *strmemb(tnode_t *, op_t, sym_t *);
+extern tnode_t *build(op_t, tnode_t *, tnode_t *);
+extern tnode_t *cconv(tnode_t *);
+extern int typeok(op_t, int, tnode_t *, tnode_t *);
+extern tnode_t *promote(op_t, int, tnode_t *);
+extern tnode_t *convert(op_t, int, type_t *, tnode_t *);
+extern void cvtcon(op_t, int, type_t *, val_t *, val_t *);
+extern const char *tyname(type_t *);
+extern tnode_t *bldszof(type_t *);
+extern tnode_t *cast(tnode_t *, type_t *);
+extern tnode_t *funcarg(tnode_t *, tnode_t *);
+extern tnode_t *funccall(tnode_t *, tnode_t *);
+extern val_t *constant(tnode_t *);
+extern void expr(tnode_t *, int, int);
+extern void chkmisc(tnode_t *, int, int, int, int, int, int);
+extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *);
+extern strg_t *catstrg(strg_t *, strg_t *);
/*
* func.c
@@ -221,42 +223,44 @@ extern pos_t scflpos;
extern int ccflg;
extern int llibflg;
extern int nowarn;
+extern int bitfieldtype_ok;
extern int plibflg;
extern int quadflg;
-extern void pushctrl __P((int));
-extern void popctrl __P((int));
-extern void chkreach __P((void));
-extern void funcdef __P((sym_t *));
-extern void funcend __P((void));
-extern void label __P((int, sym_t *, tnode_t *));
-extern void if1 __P((tnode_t *));
-extern void if2 __P((void));
-extern void if3 __P((int));
-extern void switch1 __P((tnode_t *));
-extern void switch2 __P((void));
-extern void while1 __P((tnode_t *));
-extern void while2 __P((void));
-extern void do1 __P((void));
-extern void do2 __P((tnode_t *));
-extern void for1 __P((tnode_t *, tnode_t *, tnode_t *));
-extern void for2 __P((void));
-extern void dogoto __P((sym_t *));
-extern void docont __P((void));
-extern void dobreak __P((void));
-extern void doreturn __P((tnode_t *));
-extern void glclup __P((int));
-extern void argsused __P((int));
-extern void constcond __P((int));
-extern void fallthru __P((int));
-extern void notreach __P((int));
-extern void lintlib __P((int));
-extern void linted __P((int));
-extern void varargs __P((int));
-extern void printflike __P((int));
-extern void scanflike __P((int));
-extern void protolib __P((int));
-extern void longlong __P((int));
+extern void pushctrl(int);
+extern void popctrl(int);
+extern void chkreach(void);
+extern void funcdef(sym_t *);
+extern void funcend(void);
+extern void label(int, sym_t *, tnode_t *);
+extern void if1(tnode_t *);
+extern void if2(void);
+extern void if3(int);
+extern void switch1(tnode_t *);
+extern void switch2(void);
+extern void while1(tnode_t *);
+extern void while2(void);
+extern void do1(void);
+extern void do2(tnode_t *);
+extern void for1(tnode_t *, tnode_t *, tnode_t *);
+extern void for2(void);
+extern void dogoto(sym_t *);
+extern void docont(void);
+extern void dobreak(void);
+extern void doreturn(tnode_t *);
+extern void glclup(int);
+extern void argsused(int);
+extern void constcond(int);
+extern void fallthru(int);
+extern void notreach(int);
+extern void lintlib(int);
+extern void linted(int);
+extern void varargs(int);
+extern void printflike(int);
+extern void scanflike(int);
+extern void protolib(int);
+extern void longlong(int);
+extern void bitfieldtype(int);
/*
* init.c
@@ -265,17 +269,17 @@ extern int initerr;
extern sym_t *initsym;
extern int startinit;
-extern void prepinit __P((void));
-extern void initrbr __P((void));
-extern void initlbr __P((void));
-extern void mkinit __P((tnode_t *));
+extern void prepinit(void);
+extern void initrbr(void);
+extern void initlbr(void);
+extern void mkinit(tnode_t *);
/*
* emit.c
*/
-extern void outtype __P((type_t *));
-extern const char *ttos __P((type_t *));
-extern void outsym __P((sym_t *, scl_t, def_t));
-extern void outfdef __P((sym_t *, pos_t *, int, int, sym_t *));
-extern void outcall __P((tnode_t *, int, int));
-extern void outusg __P((sym_t *));
+extern void outtype(type_t *);
+extern const char *ttos(type_t *);
+extern void outsym(sym_t *, scl_t, def_t);
+extern void outfdef(sym_t *, pos_t *, int, int, sym_t *);
+extern void outcall(tnode_t *, int, int);
+extern void outusg(sym_t *);
diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c
index 5d3a172..73ade1f 100644
--- a/usr.bin/xlint/lint1/func.c
+++ b/usr.bin/xlint/lint1/func.c
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $ */
+/* $NetBSD: func.c,v 1.16 2002/01/03 04:25:15 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,15 +31,16 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: func.c,v 1.16 2002/01/03 04:25:15 thorpej Exp $");
#endif
#include <stdlib.h>
#include <string.h>
#include "lint1.h"
-#include "y.tab.h"
+#include "cgram.h"
/*
* Contains a pointer to the symbol table entry of the current function
@@ -129,6 +130,12 @@ int llibflg;
int nowarn;
/*
+ * Nonzero if bitfield type errors are suppressed by a BITFIELDTYPE
+ * directive.
+ */
+int bitfieldtype_ok;
+
+/*
* Nonzero if complaints about use of "long long" are suppressed in
* the next statement or declaration.
*/
@@ -138,8 +145,7 @@ int quadflg;
* Puts a new element at the top of the stack used for control statements.
*/
void
-pushctrl(env)
- int env;
+pushctrl(int env)
{
cstk_t *ci;
@@ -153,8 +159,7 @@ pushctrl(env)
* Removes the top element of the stack used for control statements.
*/
void
-popctrl(env)
- int env;
+popctrl(int env)
{
cstk_t *ci;
clst_t *cl;
@@ -179,7 +184,7 @@ popctrl(env)
* Prints a warning if a statement cannot be reached.
*/
void
-chkreach()
+chkreach(void)
{
if (!reached && !rchflg) {
/* statement not reached */
@@ -199,8 +204,7 @@ chkreach()
* redeclaration etc..
*/
void
-funcdef(fsym)
- sym_t *fsym;
+funcdef(sym_t *fsym)
{
int n, warn;
sym_t *arg, *sym, *rdsym;
@@ -322,7 +326,7 @@ funcdef(fsym)
}
if (dcs->d_notyp)
- /* return value is implizitly declared to be int */
+ /* return value is implicitly declared to be int */
fsym->s_rimpl = 1;
reached = 1;
@@ -332,7 +336,7 @@ funcdef(fsym)
* Called at the end of a function definition.
*/
void
-funcend()
+funcend(void)
{
sym_t *arg;
int n;
@@ -368,7 +372,7 @@ funcend()
/*
* write the information about the function definition to the
* output file
- * inline functions explicitely declared extern are written as
+ * inline functions explicitly declared extern are written as
* declarations only.
*/
if (dcs->d_scl == EXTERN && funcsym->s_inline) {
@@ -398,14 +402,12 @@ funcend()
* tn expression if typ == T_CASE
*/
void
-label(typ, sym, tn)
- int typ;
- sym_t *sym;
- tnode_t *tn;
+label(int typ, sym_t *sym, tnode_t *tn)
{
cstk_t *ci;
clst_t *cl;
- val_t *v, *nv;
+ val_t *v;
+ val_t nv;
tspec_t t;
switch (typ) {
@@ -422,7 +424,8 @@ label(typ, sym, tn)
case T_CASE:
/* find the stack entry for the innermost switch statement */
- for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt) ;
+ for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt)
+ continue;
if (ci == NULL) {
/* case not in switch */
@@ -462,28 +465,28 @@ label(typ, sym, tn)
* to the type of the switch expression
*/
v = constant(tn);
- nv = xcalloc(1, sizeof (val_t));
- cvtcon(CASE, 0, ci->c_swtype, nv, v);
+ (void) memset(&nv, 0, sizeof nv);
+ cvtcon(CASE, 0, ci->c_swtype, &nv, v);
free(v);
/* look if we had this value already */
for (cl = ci->c_clst; cl != NULL; cl = cl->cl_nxt) {
- if (cl->cl_val.v_quad == nv->v_quad)
+ if (cl->cl_val.v_quad == nv.v_quad)
break;
}
- if (cl != NULL && isutyp(nv->v_tspec)) {
+ if (cl != NULL && isutyp(nv.v_tspec)) {
/* duplicate case in switch, %lu */
- error(200, (u_long)nv->v_quad);
+ error(200, (u_long)nv.v_quad);
} else if (cl != NULL) {
/* duplicate case in switch, %ld */
- error(199, (long)nv->v_quad);
+ error(199, (long)nv.v_quad);
} else {
/*
* append the value to the list of
* case values
*/
cl = xcalloc(1, sizeof (clst_t));
- STRUCT_ASSIGN(cl->cl_val, *nv);
+ STRUCT_ASSIGN(cl->cl_val, nv);
cl->cl_nxt = ci->c_clst;
ci->c_clst = cl;
}
@@ -494,7 +497,8 @@ label(typ, sym, tn)
case T_DEFAULT:
/* find the stack entry for the innermost switch statement */
- for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt) ;
+ for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt)
+ continue;
if (ci == NULL) {
/* default outside switch */
@@ -519,9 +523,9 @@ label(typ, sym, tn)
* T_IF T_LPARN expr T_RPARN
*/
void
-if1(tn)
- tnode_t *tn;
+if1(tnode_t *tn)
{
+
if (tn != NULL)
tn = cconv(tn);
if (tn != NULL)
@@ -535,8 +539,9 @@ if1(tn)
* if_without_else T_ELSE
*/
void
-if2()
+if2(void)
{
+
cstk->c_rchif = reached ? 1 : 0;
reached = 1;
}
@@ -546,9 +551,9 @@ if2()
* if_without_else T_ELSE stmnt
*/
void
-if3(els)
- int els;
+if3(int els)
{
+
if (els) {
reached |= cstk->c_rchif;
} else {
@@ -561,8 +566,7 @@ if3(els)
* T_SWITCH T_LPARN expr T_RPARN
*/
void
-switch1(tn)
- tnode_t *tn;
+switch1(tnode_t *tn)
{
tspec_t t;
type_t *tp;
@@ -613,9 +617,9 @@ switch1(tn)
* switch_expr stmnt
*/
void
-switch2()
+switch2(void)
{
- int nenum, nclab;
+ int nenum = 0, nclab = 0;
sym_t *esym;
clst_t *cl;
@@ -668,9 +672,9 @@ switch2()
* T_WHILE T_LPARN expr T_RPARN
*/
void
-while1(tn)
- tnode_t *tn;
+while1(tnode_t *tn)
{
+
if (!reached) {
/* loop not entered at top */
warning(207);
@@ -705,8 +709,9 @@ while1(tn)
* while_expr error
*/
void
-while2()
+while2(void)
{
+
/*
* The end of the loop can be reached if it is no endless loop
* or there was a break statement which was reached.
@@ -721,8 +726,9 @@ while2()
* T_DO
*/
void
-do1()
+do1(void)
{
+
if (!reached) {
/* loop not entered at top */
warning(207);
@@ -738,9 +744,9 @@ do1()
* do error
*/
void
-do2(tn)
- tnode_t *tn;
+do2(tnode_t *tn)
{
+
/*
* If there was a continue statement the expression controlling the
* loop is reached.
@@ -782,9 +788,9 @@ do2(tn)
* T_FOR T_LPARN opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPARN
*/
void
-for1(tn1, tn2, tn3)
- tnode_t *tn1, *tn2, *tn3;
+for1(tnode_t *tn1, tnode_t *tn2, tnode_t *tn3)
{
+
/*
* If there is no initialisation expression it is possible that
* it is intended not to enter the loop at top.
@@ -843,7 +849,7 @@ for1(tn1, tn2, tn3)
* for_exprs error
*/
void
-for2()
+for2(void)
{
pos_t cpos, cspos;
tnode_t *tn3;
@@ -888,9 +894,9 @@ for2()
* T_GOTO error T_SEMI
*/
void
-dogoto(lab)
- sym_t *lab;
+dogoto(sym_t *lab)
{
+
setuflg(lab, 0, 0);
chkreach();
@@ -902,7 +908,7 @@ dogoto(lab)
* T_BREAK T_SEMI
*/
void
-dobreak()
+dobreak(void)
{
cstk_t *ci;
@@ -928,11 +934,12 @@ dobreak()
* T_CONTINUE T_SEMI
*/
void
-docont()
+docont(void)
{
cstk_t *ci;
- for (ci = cstk; ci != NULL && !ci->c_loop; ci = ci->c_nxt) ;
+ for (ci = cstk; ci != NULL && !ci->c_loop; ci = ci->c_nxt)
+ continue;
if (ci == NULL) {
/* continue outside loop */
@@ -951,14 +958,14 @@ docont()
* T_RETURN expr T_SEMI
*/
void
-doreturn(tn)
- tnode_t *tn;
+doreturn(tnode_t *tn)
{
tnode_t *ln, *rn;
cstk_t *ci;
op_t op;
- for (ci = cstk; ci->c_nxt != NULL; ci = ci->c_nxt) ;
+ for (ci = cstk; ci->c_nxt != NULL; ci = ci->c_nxt)
+ continue;
if (tn != NULL) {
ci->c_retval = 1;
@@ -1020,8 +1027,7 @@ doreturn(tn)
* Especially remove informations about unused lint comments.
*/
void
-glclup(silent)
- int silent;
+glclup(int silent)
{
pos_t cpos;
@@ -1072,9 +1078,9 @@ glclup(silent)
* for usage. A missing argument is taken to be 0.
*/
void
-argsused(n)
- int n;
+argsused(int n)
{
+
if (n == -1)
n = 0;
@@ -1098,9 +1104,9 @@ argsused(n)
* to the function definition. A missing argument is taken to be 0.
*/
void
-varargs(n)
- int n;
+varargs(int n)
{
+
if (n == -1)
n = 0;
@@ -1124,9 +1130,9 @@ varargs(n)
* used the check the types of remaining arguments.
*/
void
-printflike(n)
- int n;
+printflike(int n)
{
+
if (n == -1)
n = 0;
@@ -1150,9 +1156,9 @@ printflike(n)
* used the check the types of remaining arguments.
*/
void
-scanflike(n)
- int n;
+scanflike(int n)
{
+
if (n == -1)
n = 0;
@@ -1175,9 +1181,9 @@ scanflike(n)
*/
/* ARGSUSED */
void
-constcond(n)
- int n;
+constcond(int n)
{
+
ccflg = 1;
}
@@ -1187,9 +1193,9 @@ constcond(n)
*/
/* ARGSUSED */
void
-fallthru(n)
- int n;
+fallthru(int n)
{
+
ftflg = 1;
}
@@ -1199,18 +1205,18 @@ fallthru(n)
*/
/* ARGSUSED */
void
-notreach(n)
- int n;
+notreach(int n)
{
+
reached = 0;
rchflg = 1;
}
/* ARGSUSED */
void
-lintlib(n)
- int n;
+lintlib(int n)
{
+
if (dcs->d_ctx != EXTERN) {
/* must be outside function: ** %s ** */
warning(280, "LINTLIBRARY");
@@ -1225,21 +1231,39 @@ lintlib(n)
*/
/* ARGSUSED */
void
-linted(n)
- int n;
+linted(int n)
{
+
+#ifdef DEBUG
+ printf("%s, %d: nowarn = 1\n", curr_pos.p_file, curr_pos.p_line);
+#endif
nowarn = 1;
}
/*
+ * Suppress bitfield type errors on the current line.
+ */
+/* ARGSUSED */
+void
+bitfieldtype(int n)
+{
+
+#ifdef DEBUG
+ printf("%s, %d: bitfieldtype_ok = 1\n", curr_pos.p_file,
+ curr_pos.p_line);
+#endif
+ bitfieldtype_ok = 1;
+}
+
+/*
* PROTOTLIB in conjunction with LINTLIBRARY can be used to handle
* prototypes like function definitions. This is done if the argument
* to PROTOLIB is nonzero. Otherwise prototypes are handled normaly.
*/
void
-protolib(n)
- int n;
+protolib(int n)
{
+
if (dcs->d_ctx != EXTERN) {
/* must be outside function: ** %s ** */
warning(280, "PROTOLIB");
@@ -1254,8 +1278,8 @@ protolib(n)
*/
/* ARGSUSED */
void
-longlong(n)
- int n;
+longlong(int n)
{
+
quadflg = 1;
}
diff --git a/usr.bin/xlint/lint1/init.c b/usr.bin/xlint/lint1/init.c
index dbd216b..0fd0383 100644
--- a/usr.bin/xlint/lint1/init.c
+++ b/usr.bin/xlint/lint1/init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.4 1995/10/02 17:21:37 jpo Exp $ */
+/* $NetBSD: init.c,v 1.9 2001/09/18 18:15:54 wiz Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,8 +31,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: init.c,v 1.4 1995/10/02 17:21:37 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: init.c,v 1.9 2001/09/18 18:15:54 wiz Exp $");
#endif
#include <stdlib.h>
@@ -40,7 +41,7 @@ static char rcsid[] = "$NetBSD: init.c,v 1.4 1995/10/02 17:21:37 jpo Exp $";
#include "lint1.h"
/*
- * initerr is set as soon as a fatal error occured in an initialisation.
+ * initerr is set as soon as a fatal error occurred in an initialisation.
* The effect is that the rest of the initialisation is ignored (parsed
* by yacc, expression trees built, but no initialisation takes place).
*/
@@ -53,12 +54,12 @@ sym_t *initsym;
istk_t *initstk;
-static void popi2 __P((void));
-static void popinit __P((int));
-static void pushinit __P((void));
-static void testinit __P((void));
-static void nextinit __P((int));
-static int strginit __P((tnode_t *));
+static void popi2(void);
+static void popinit(int);
+static void pushinit(void);
+static void testinit(void);
+static void nextinit(int);
+static int strginit(tnode_t *);
/*
@@ -66,7 +67,7 @@ static int strginit __P((tnode_t *));
* which is to be initialized on it.
*/
void
-prepinit()
+prepinit(void)
{
istk_t *istk;
@@ -93,7 +94,7 @@ prepinit()
}
static void
-popi2()
+popi2(void)
{
istk_t *istk;
sym_t *m;
@@ -124,9 +125,9 @@ popi2()
}
static void
-popinit(brace)
- int brace;
+popinit(int brace)
{
+
if (brace) {
/*
* Take all entries, including the first which requires
@@ -150,7 +151,7 @@ popinit(brace)
}
static void
-pushinit()
+pushinit(void)
{
istk_t *istk;
int cnt;
@@ -235,7 +236,7 @@ pushinit()
}
static void
-testinit()
+testinit(void)
{
istk_t *istk;
@@ -266,9 +267,9 @@ testinit()
}
static void
-nextinit(brace)
- int brace;
+nextinit(int brace)
{
+
if (!brace) {
if (initstk->i_type == NULL &&
!issclt(initstk->i_subt->t_tspec)) {
@@ -303,8 +304,9 @@ nextinit(brace)
}
void
-initlbr()
+initlbr(void)
{
+
if (initerr)
return;
@@ -325,8 +327,9 @@ initlbr()
}
void
-initrbr()
+initrbr(void)
{
+
if (initerr)
return;
@@ -334,8 +337,7 @@ initrbr()
}
void
-mkinit(tn)
- tnode_t *tn;
+mkinit(tnode_t *tn)
{
ptrdiff_t offs;
sym_t *sym;
@@ -351,7 +353,7 @@ mkinit(tn)
/*
* Do not test for automatic aggregat initialisation. If the
- * initalizer starts with a brace we have the warning already.
+ * initializer starts with a brace we have the warning already.
* If not, an error will be printed that the initializer must
* be enclosed by braces.
*/
@@ -412,7 +414,7 @@ mkinit(tn)
tmem = tsave();
expr(tn, 1, 0);
trestor(tmem);
-
+
if (isityp(lt) && ln->tn_type->t_isfield && !isityp(rt)) {
/*
* Bit-fields can be initialized in trad. C only by integer
@@ -446,8 +448,7 @@ mkinit(tn)
static int
-strginit(tn)
- tnode_t *tn;
+strginit(tnode_t *tn)
{
tspec_t t;
istk_t *istk;
diff --git a/usr.bin/xlint/lint1/lint1.h b/usr.bin/xlint/lint1/lint1.h
index 019c98d..278019e 100644
--- a/usr.bin/xlint/lint1/lint1.h
+++ b/usr.bin/xlint/lint1/lint1.h
@@ -1,6 +1,7 @@
-/* $NetBSD: lint1.h,v 1.6 1995/10/02 17:31:41 jpo Exp $ */
+/* $NetBSD: lint1.h,v 1.12 2002/01/31 19:33:27 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -34,14 +35,29 @@
#include "lint.h"
#include "op.h"
+/* XXX - works for most systems, but the whole ALIGN thing needs to go away */
+#ifndef ALIGN
+#define ALIGN(x) (((x) + 7) & ~7)
+#endif
+
/*
* Describes the position of a declaration or anything else.
*/
typedef struct {
int p_line;
const char *p_file;
+ int p_uniq; /* uniquifier */
} pos_t;
+/* Copies curr_pos, keeping things unique. */
+#define UNIQUE_CURR_POS(pos) \
+ do { \
+ STRUCT_ASSIGN((pos), curr_pos); \
+ curr_pos.p_uniq++; \
+ if (curr_pos.p_file == csrc_pos.p_file) \
+ csrc_pos.p_uniq++; \
+ } while (0)
+
/*
* Strings cannot be referenced to simply by a pointer to its first
* char. This is because strings can contain NUL characters other than the
@@ -76,7 +92,7 @@ typedef struct {
int v_ansiu; /* set if an integer constant is
unsigned in ANSI C */
union {
- quad_t _v_quad; /* integers */
+ int64_t _v_quad; /* integers */
ldbl_t _v_ldbl; /* floats */
} v_u;
} val_t;
@@ -132,11 +148,11 @@ typedef struct type {
str_t *_t_str; /* struct/union tag */
enum_t *_t_enum; /* enum tag */
struct sym *_t_args; /* arguments (if t_proto) */
- struct {
- u_int _t_flen : 8; /* length of bit-field */
- u_int _t_foffs : 24; /* offset of bit-field */
- } _t_u;
} t_u;
+ struct {
+ u_int _t_flen : 8; /* length of bit-field */
+ u_int _t_foffs : 24; /* offset of bit-field */
+ } t_b;
struct type *t_subt; /* element type (arrays), return value
(functions), or type pointer points to */
} type_t;
@@ -146,8 +162,8 @@ typedef struct type {
#define t_field t_u._t_field
#define t_enum t_u._t_enum
#define t_args t_u._t_args
-#define t_flen t_u._t_u._t_flen
-#define t_foffs t_u._t_u._t_foffs
+#define t_flen t_b._t_flen
+#define t_foffs t_b._t_foffs
/*
* types of symbols
@@ -187,6 +203,7 @@ typedef enum {
*/
typedef struct sym {
const char *s_name; /* name */
+ const char *s_rename; /* renamed symbol's given name */
pos_t s_dpos; /* position of last (prototype)definition,
prototypedeclaration, no-prototype-def.,
tentative definition or declaration,
@@ -378,3 +395,20 @@ typedef struct cstk {
} cstk_t;
#include "externs1.h"
+
+#define ERR_SETSIZE 1024
+#define __NERRBITS (sizeof(unsigned int))
+
+typedef struct err_set {
+ unsigned int errs_bits[(ERR_SETSIZE + __NERRBITS-1) / __NERRBITS];
+} err_set;
+
+#define ERR_SET(n, p) \
+ ((p)->errs_bits[(n)/__NERRBITS] |= (1 << ((n) % __NERRBITS)))
+#define ERR_CLR(n, p) \
+ ((p)->errs_bits[(n)/__NERRBITS] &= ~(1 << ((n) % __NERRBITS)))
+#define ERR_ISSET(n, p) \
+ ((p)->errs_bits[(n)/__NERRBITS] & (1 << ((n) % __NERRBITS)))
+#define ERR_ZERO(p) (void)memset((p), 0, sizeof(*(p)))
+
+extern err_set msgset;
diff --git a/usr.bin/xlint/lint1/main1.c b/usr.bin/xlint/lint1/main1.c
index 0add206..f04d817 100644
--- a/usr.bin/xlint/lint1/main1.c
+++ b/usr.bin/xlint/lint1/main1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $ */
+/* $NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,14 +31,18 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $");
#endif
+#include <sys/types.h>
#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include <err.h>
+#include <errno.h>
+#include <limits.h>
#include "lint1.h"
@@ -49,7 +53,7 @@ int yflag;
* Print warnings if an assignment of an integertype to another integertype
* causes an implizit narrowing conversion. If aflag is 1, these warnings
* are printed only if the source type is at least as wide as long. If aflag
- * is greather then 1, they are always printed.
+ * is greater than 1, they are always printed.
*/
int aflag;
@@ -71,6 +75,9 @@ int Fflag;
/* Enable some extensions of gcc */
int gflag;
+/* Treat warnings as errors */
+int wflag;
+
/*
* Apply a number of heuristic tests to attempt to intuit bugs, improve
* style, and reduce waste.
@@ -104,16 +111,22 @@ int vflag = 1;
/* Complain about structures which are never defined. */
int zflag = 1;
-static void usage __P((void));
+err_set msgset;
+
+static void usage(void);
+
+int main(int, char *[]);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int c;
+ char *ptr;
- while ((c = getopt(argc, argv, "abcdeghprstuvyzF")) != -1) {
+ setprogname(argv[0]);
+
+ ERR_ZERO(&msgset);
+ while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFX:")) != -1) {
switch (c) {
case 'a': aflag++; break;
case 'b': bflag = 1; break;
@@ -128,10 +141,35 @@ main(argc, argv)
case 's': sflag = 1; break;
case 't': tflag = 1; break;
case 'u': uflag = 0; break;
+ case 'w': wflag = 1; break;
case 'v': vflag = 0; break;
case 'y': yflag = 1; break;
case 'z': zflag = 0; break;
- case '?': usage();
+
+ case 'm':
+ msglist();
+ return(0);
+
+ case 'X':
+ for (ptr = strtok(optarg, ","); ptr;
+ ptr = strtok(NULL, ",")) {
+ char *eptr;
+ long msg = strtol(ptr, &eptr, 0);
+ if ((msg == LONG_MIN || msg == LONG_MAX) &&
+ errno == ERANGE)
+ err(1, "invalid error message id '%s'",
+ ptr);
+ if (*eptr || ptr == eptr || msg < 0 ||
+ msg >= ERR_SETSIZE)
+ errx(1, "invalid error message id '%s'",
+ ptr);
+ ERR_SET(msg, &msgset);
+ }
+ break;
+ case '?':
+ default:
+ usage();
+ break;
}
}
argc -= optind;
@@ -168,14 +206,16 @@ main(argc, argv)
}
static void
-usage()
+usage(void)
{
- (void)fprintf(stderr, "usage: lint1 [-abcdeghprstuvyzF] src dest\n");
+ (void)fprintf(stderr,
+ "Usage: %s [-abcdeghmprstuvwyzF] [-X <id>[,<id>]... src dest\n",
+ getprogname());
exit(1);
}
-
+
void
-norecover()
+norecover(void)
{
/* cannot recover from previous errors */
error(224);
diff --git a/usr.bin/xlint/lint1/makeman b/usr.bin/xlint/lint1/makeman
new file mode 100644
index 0000000..721e825
--- /dev/null
+++ b/usr.bin/xlint/lint1/makeman
@@ -0,0 +1,94 @@
+#!/bin/sh
+# $NetBSD$
+#
+# Copyright (c) 2000 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+cat << \__EOF
+.\" $NetBSD$
+.\"
+.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.Dd July 5, 2000
+.Dt LINT 7
+.Os
+.Sh NAME
+.Nm lint
+.Nd Lint error message list
+.Sh DESCRIPTION
+The following is a list of message id's and messages produced by
+.Xr lint 1 .
+It is intended to be used with
+.Fl X
+flag of
+.Xr lint 1 .
+.Pp
+.Bd -ragged -offset indent -compact
+.Bl -column "Id# Message"
+__EOF
+"$@" | sed -e 's/^/.It /' -e 's/\\/\\e/g' -e "s/'/\\'/"
+echo ".El"
+echo ".Ed"
diff --git a/usr.bin/xlint/lint1/mem1.c b/usr.bin/xlint/lint1/mem1.c
index df880b1..4e21f07 100644
--- a/usr.bin/xlint/lint1/mem1.c
+++ b/usr.bin/xlint/lint1/mem1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.2 1995/07/03 21:24:25 cgd Exp $ */
+/* $NetBSD: mem1.c,v 1.6 2002/01/29 02:43:39 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,8 +31,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: mem1.c,v 1.2 1995/07/03 21:24:25 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: mem1.c,v 1.6 2002/01/29 02:43:39 tv Exp $");
#endif
#include <sys/types.h>
@@ -41,7 +42,6 @@ static char rcsid[] = "$NetBSD: mem1.c,v 1.2 1995/07/03 21:24:25 cgd Exp $";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <err.h>
#include "lint1.h"
@@ -57,15 +57,13 @@ typedef struct fn {
static fn_t *fnames;
-static fn_t *srchfn __P((const char *, size_t));
+static fn_t *srchfn(const char *, size_t);
/*
* Look for a Filename of length l.
*/
static fn_t *
-srchfn(s, len)
- const char *s;
- size_t len;
+srchfn(const char *s, size_t len)
{
fn_t *fn;
@@ -80,16 +78,14 @@ srchfn(s, len)
* Return a shared string for filename s.
*/
const char *
-fnalloc(s)
- const char *s;
+fnalloc(const char *s)
{
+
return (s != NULL ? fnnalloc(s, strlen(s)) : NULL);
}
const char *
-fnnalloc(s, len)
- const char *s;
- size_t len;
+fnnalloc(const char *s, size_t len)
{
fn_t *fn;
@@ -121,8 +117,7 @@ fnnalloc(s, len)
* Get id of a filename.
*/
int
-getfnid(s)
- const char *s;
+getfnid(const char *s)
{
fn_t *fn;
@@ -163,12 +158,12 @@ static mbl_t *frmblks;
/* length of new allocated memory blocks */
static size_t mblklen;
-static void *xgetblk __P((mbl_t **, size_t));
-static void xfreeblk __P((mbl_t **));
-static mbl_t *xnewblk __P((void));
+static void *xgetblk(mbl_t **, size_t);
+static void xfreeblk(mbl_t **);
+static mbl_t *xnewblk(void);
static mbl_t *
-xnewblk()
+xnewblk(void)
{
mbl_t *mb;
int prot, flags;
@@ -182,8 +177,6 @@ xnewblk()
mb->blk = mmap(NULL, mblklen, prot, flags, -1, (off_t)0);
if (mb->blk == (void *)-1)
err(1, "can't map memory");
- if (ALIGN((u_long)mb->blk) != (u_long)mb->blk)
- errx(1, "mapped address is not aligned");
mb->size = mblklen;
@@ -199,9 +192,7 @@ xnewblk()
* zero'd in xfreeblk().
*/
static void *
-xgetblk(mbp, s)
- mbl_t **mbp;
- size_t s;
+xgetblk(mbl_t **mbp, size_t s)
{
mbl_t *mb;
void *p;
@@ -230,8 +221,7 @@ xgetblk(mbp, s)
* used memory to zero.
*/
static void
-xfreeblk(fmbp)
- mbl_t **fmbp;
+xfreeblk(mbl_t **fmbp)
{
mbl_t *mb;
@@ -244,7 +234,7 @@ xfreeblk(fmbp)
}
void
-initmem()
+initmem(void)
{
int pgsz;
@@ -254,15 +244,14 @@ initmem()
mblks = xcalloc(nmblks = ML_INC, sizeof (mbl_t *));
}
-
+
/*
* Allocate memory associated with level l.
*/
void *
-getlblk(l, s)
- int l;
- size_t s;
+getlblk(int l, size_t s)
{
+
while (l >= nmblks) {
mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof (mbl_t *));
(void)memset(&mblks[nmblks], 0, ML_INC * sizeof (mbl_t *));
@@ -272,9 +261,9 @@ getlblk(l, s)
}
void *
-getblk(s)
- size_t s;
+getblk(size_t s)
{
+
return (getlblk(mblklev, s));
}
@@ -282,15 +271,16 @@ getblk(s)
* Free all memory associated with level l.
*/
void
-freelblk(l)
- int l;
+freelblk(int l)
{
+
xfreeblk(&mblks[l]);
}
void
-freeblk()
+freeblk(void)
{
+
freelblk(mblklev);
}
@@ -301,9 +291,9 @@ freeblk()
static mbl_t *tmblk;
void *
-tgetblk(s)
- size_t s;
+tgetblk(size_t s)
{
+
return (xgetblk(&tmblk, s));
}
@@ -311,17 +301,19 @@ tgetblk(s)
* Get memory for a new tree node.
*/
tnode_t *
-getnode()
+getnode(void)
{
+
return (tgetblk(sizeof (tnode_t)));
}
/*
- * Free all memory which is allocated by the the current expression.
+ * Free all memory which is allocated by the current expression.
*/
void
-tfreeblk()
+tfreeblk(void)
{
+
xfreeblk(&tmblk);
}
@@ -331,7 +323,7 @@ tfreeblk()
* used to restore the memory.
*/
mbl_t *
-tsave()
+tsave(void)
{
mbl_t *tmem;
@@ -346,9 +338,9 @@ tsave()
* tfreeblk() frees the restored memory.
*/
void
-trestor(tmem)
- mbl_t *tmem;
+trestor(mbl_t *tmem)
{
+
tfreeblk();
if (tmblk != NULL) {
free(tmblk->blk);
diff --git a/usr.bin/xlint/lint1/op.h b/usr.bin/xlint/lint1/op.h
index 11f05a5..042195a 100644
--- a/usr.bin/xlint/lint1/op.h
+++ b/usr.bin/xlint/lint1/op.h
@@ -48,7 +48,7 @@ typedef struct {
u_int m_tlansiu : 1; /* warning if left op. is unsign. in ANSI C */
u_int m_transiu : 1; /* warning if right op. is unsign. in ANSI C */
u_int m_tpconf : 1; /* test possible precedence confusion */
- u_int m_comp : 1; /* op. performs comparision */
+ u_int m_comp : 1; /* op. performs comparison */
u_int m_enumop : 1; /* valid operation on enums */
u_int m_badeop : 1; /* dubious operation on enums */
u_int m_eqwarn : 1; /* warning if on operand stems from == */
diff --git a/usr.bin/xlint/lint1/scan.l b/usr.bin/xlint/lint1/scan.l
index 5e23c6b..bd18f73 100644
--- a/usr.bin/xlint/lint1/scan.l
+++ b/usr.bin/xlint/lint1/scan.l
@@ -1,7 +1,8 @@
%{
-/* $NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $ */
+/* $NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -32,8 +33,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $");
#endif
#include <stdlib.h>
@@ -43,44 +45,42 @@ static char rcsid[] = "$NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $";
#include <ctype.h>
#include <errno.h>
#include <math.h>
-#include <err.h>
#include "lint1.h"
-#include "y.tab.h"
+#include "cgram.h"
#define CHAR_MASK (~(~0 << CHAR_BIT))
-
-/* XXX declaration of strtouq() is missing in stdlib.h ? */
-extern u_quad_t strtouq __P((const char *, char **, int));
+#define YY_NO_UNPUT
/* Current position (its also updated when an included file is parsed) */
-pos_t curr_pos = { 1, "" };
+pos_t curr_pos = { 1, "", 0 };
/*
* Current position in C source (not updated when an included file is
* parsed).
*/
-pos_t csrc_pos = { 1, "" };
-
-static void incline __P((void));
-static void badchar __P((int));
-static sbuf_t *allocsb __P((void));
-static void freesb __P((sbuf_t *));
-static int inpc __P((void));
-static int hash __P((const char *));
-static sym_t *search __P((sbuf_t *));
-static int name __P((void));
-static int keyw __P((sym_t *));
-static int icon __P((int));
-static int fcon __P((void));
-static int operator __P((int, op_t));
-static int ccon __P((void));
-static int wccon __P((void));
-static int getescc __P((int));
-static void directive __P((void));
-static void comment __P((void));
-static int string __P((void));
-static int wcstrg __P((void));
+pos_t csrc_pos = { 1, "", 0 };
+
+static void incline(void);
+static void badchar(int);
+static sbuf_t *allocsb(void);
+static void freesb(sbuf_t *);
+static int inpc(void);
+static int hash(const char *);
+static sym_t *search(sbuf_t *);
+static int name(void);
+static int keyw(sym_t *);
+static int icon(int);
+static int fcon(void);
+static int operator(int, op_t);
+static int ccon(void);
+static int wccon(void);
+static int getescc(int);
+static void directive(void);
+static void comment(void);
+static void slashslashcomment(void);
+static int string(void);
+static int wcstrg(void);
%}
@@ -154,22 +154,26 @@ EX ([eE][+-]?[0-9]+)
\n incline();
\t|" "|\f|\v ;
"/*" comment();
+"//" slashslashcomment();
. badchar(yytext[0]);
%%
static void
-incline()
+incline(void)
{
curr_pos.p_line++;
- if (curr_pos.p_file == csrc_pos.p_file)
+ curr_pos.p_uniq = 0;
+ if (curr_pos.p_file == csrc_pos.p_file) {
csrc_pos.p_line++;
+ csrc_pos.p_uniq = 0;
+ }
}
static void
-badchar(c)
- int c;
+badchar(int c)
{
+
/* unknown character \%o */
error(250, c);
}
@@ -212,6 +216,7 @@ static struct kwtab {
{ "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0 },
{ "__inline", T_SCLASS, INLINE, 0, 0, 0, 0 },
{ "int", T_TYPE, 0, INT, 0, 0, 0 },
+ { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0 },
{ "long", T_TYPE, 0, LONG, 0, 0, 0 },
{ "register", T_SCLASS, REG, 0, 0, 0, 0 },
{ "return", T_RETURN, 0, 0, 0, 0, 0 },
@@ -238,13 +243,13 @@ static struct kwtab {
static sym_t *symtab[HSHSIZ1];
/* bit i of the entry with index i is set */
-u_quad_t qbmasks[sizeof(u_quad_t) * CHAR_BIT];
+uint64_t qbmasks[sizeof(uint64_t) * CHAR_BIT];
/* least significant i bits are set in the entry with index i */
-u_quad_t qlmasks[sizeof(u_quad_t) * CHAR_BIT + 1];
+uint64_t qlmasks[sizeof(uint64_t) * CHAR_BIT + 1];
/* least significant i bits are not set in the entry with index i */
-u_quad_t qumasks[sizeof(u_quad_t) * CHAR_BIT + 1];
+uint64_t qumasks[sizeof(uint64_t) * CHAR_BIT + 1];
/* free list for sbuf structures */
static sbuf_t *sbfrlst;
@@ -258,12 +263,12 @@ symt_t symtyp;
* in a extra table for each name we found.
*/
void
-initscan()
+initscan(void)
{
struct kwtab *kw;
sym_t *sym;
int h, i;
- u_quad_t uq;
+ uint64_t uq;
for (kw = kwtab; kw->kw_name != NULL; kw++) {
if (kw->kw_stdc && tflag)
@@ -288,21 +293,21 @@ initscan()
}
/* initialize bit-masks for quads */
- for (i = 0; i < sizeof (u_quad_t) * CHAR_BIT; i++) {
- qbmasks[i] = (u_quad_t)1 << i;
- uq = ~(u_quad_t)0 << i;
+ for (i = 0; i < sizeof (uint64_t) * CHAR_BIT; i++) {
+ qbmasks[i] = (uint64_t)1 << i;
+ uq = ~(uint64_t)0 << i;
qumasks[i] = uq;
qlmasks[i] = ~uq;
}
qumasks[i] = 0;
- qlmasks[i] = ~(u_quad_t)0;
+ qlmasks[i] = ~(uint64_t)0;
}
/*
* Get a free sbuf structure, if possible from the free list
*/
static sbuf_t *
-allocsb()
+allocsb(void)
{
sbuf_t *sb;
@@ -319,9 +324,9 @@ allocsb()
* Put a sbuf structure to the free list
*/
static void
-freesb(sb)
- sbuf_t *sb;
+freesb(sbuf_t *sb)
{
+
sb->sb_nxt = sbfrlst;
sbfrlst = sb;
}
@@ -331,7 +336,7 @@ freesb(sb)
* Increment line count(s) if necessary.
*/
static int
-inpc()
+inpc(void)
{
int c;
@@ -341,8 +346,7 @@ inpc()
}
static int
-hash(s)
- const char *s;
+hash(const char *s)
{
u_int v;
const u_char *us;
@@ -371,7 +375,7 @@ hash(s)
* to the symbol table entry.
*/
static int
-name()
+name(void)
{
char *s;
sbuf_t *sb;
@@ -409,8 +413,7 @@ name()
}
static sym_t *
-search(sb)
- sbuf_t *sb;
+search(sbuf_t *sb)
{
sym_t *sym;
@@ -423,10 +426,9 @@ search(sb)
return (NULL);
}
-
+
static int
-keyw(sym)
- sym_t *sym;
+keyw(sym_t *sym)
{
int t;
@@ -445,16 +447,15 @@ keyw(sym)
* The value is returned in yylval. icon() (and yylex()) returns T_CON.
*/
static int
-icon(base)
- int base;
+icon(int base)
{
int l_suffix, u_suffix;
int len;
const char *cp;
char c, *eptr;
tspec_t typ;
- u_long ul;
- u_quad_t uq;
+ u_long ul = 0;
+ uint64_t uq = 0;
int ansiu;
static tspec_t contypes[2][3] = {
{ INT, LONG, QUAD },
@@ -509,7 +510,7 @@ icon(base)
warning(252);
/*
- * If the value is to big for the current type, we must choose
+ * If the value is to big for the current type, we must choose
* another type.
*/
ansiu = 0;
@@ -555,21 +556,45 @@ icon(base)
}
break;
/* LINTED (enumeration values not handled in switch) */
+ case STRUCT:
+ case VOID:
+ case LDOUBLE:
+ case FUNC:
+ case ARRAY:
+ case PTR:
+ case ENUM:
+ case UNION:
+ case SIGNED:
+ case NOTSPEC:
+ case DOUBLE:
+ case FLOAT:
+ case UQUAD:
+ case ULONG:
+ case USHORT:
+ case SHORT:
+ case UCHAR:
+ case SCHAR:
+ case CHAR:
+ case UNSIGN:
+ break;
+
+ case NTSPEC: /* this value unused */
+ break;
}
if (typ != QUAD && typ != UQUAD) {
if (isutyp(typ)) {
uq = ul;
} else {
- uq = (quad_t)(long)ul;
+ uq = (int64_t)(long)ul;
}
}
- uq = (u_quad_t)xsign((quad_t)uq, typ, -1);
+ uq = (uint64_t)xsign((int64_t)uq, typ, -1);
(yylval.y_val = xcalloc(1, sizeof (val_t)))->v_tspec = typ;
yylval.y_val->v_ansiu = ansiu;
- yylval.y_val->v_quad = (quad_t)uq;
+ yylval.y_val->v_quad = (int64_t)uq;
return (T_CON);
}
@@ -581,22 +606,18 @@ icon(base)
* to the width of type t.
*/
int
-sign(q, t, len)
- quad_t q;
- tspec_t t;
- int len;
+sign(int64_t q, tspec_t t, int len)
{
+
if (t == PTR || isutyp(t))
return (0);
return (msb(q, t, len));
}
int
-msb(q, t, len)
- quad_t q;
- tspec_t t;
- int len;
+msb(int64_t q, tspec_t t, int len)
{
+
if (len <= 0)
len = size(t);
return ((q & qbmasks[len - 1]) != 0);
@@ -605,12 +626,10 @@ msb(q, t, len)
/*
* Extends the sign of q.
*/
-quad_t
-xsign(q, t, len)
- quad_t q;
- tspec_t t;
- int len;
+int64_t
+xsign(int64_t q, tspec_t t, int len)
{
+
if (len <= 0)
len = size(t);
@@ -627,17 +646,17 @@ xsign(q, t, len)
* representation. Type and value are returned in yylval. fcon()
* (and yylex()) returns T_CON.
* XXX Currently it is not possible to convert constants of type
- * long double which are greater then DBL_MAX.
+ * long double which are greater than DBL_MAX.
*/
static int
-fcon()
+fcon(void)
{
const char *cp;
int len;
tspec_t typ;
char c, *eptr;
double d;
- float f;
+ float f = 0;
cp = yytext;
len = yyleng;
@@ -667,7 +686,7 @@ fcon()
if (typ == FLOAT) {
f = (float)d;
- if (isinf(f)) {
+ if (!finite(f)) {
/* floating-point constant out of range */
warning(248);
f = f > 0 ? FLT_MAX : -FLT_MAX;
@@ -685,10 +704,9 @@ fcon()
}
static int
-operator(t, o)
- int t;
- op_t o;
+operator(int t, op_t o)
{
+
yylval.y_op = o;
return (t);
}
@@ -697,7 +715,7 @@ operator(t, o)
* Called if lex found a leading \'.
*/
static int
-ccon()
+ccon(void)
{
int n, val, c;
char cv;
@@ -727,7 +745,7 @@ ccon()
cv = (char)val;
val = cv;
}
-
+
yylval.y_val = xcalloc(1, sizeof (val_t));
yylval.y_val->v_tspec = INT;
yylval.y_val->v_quad = val;
@@ -739,7 +757,7 @@ ccon()
* Called if lex found a leading L\'
*/
static int
-wccon()
+wccon(void)
{
static char buf[MB_LEN_MAX + 1];
int i, c;
@@ -789,11 +807,10 @@ wccon()
* string.
*
* Returns -1 if the end of the character constant or string is reached,
- * -2 if the EOF is reached, and the charachter otherwise.
+ * -2 if the EOF is reached, and the character otherwise.
*/
static int
-getescc(d)
- int d;
+getescc(int d)
{
static int pbc = -1;
int n, c, v;
@@ -808,9 +825,12 @@ getescc(d)
return (-1);
switch (c) {
case '\n':
- /* newline in string or char constant */
- error(254);
- return (-2);
+ if (tflag) {
+ /* newline in string or char constant */
+ error(254);
+ return (-2);
+ }
+ return (c);
case EOF:
return (-2);
case '\\':
@@ -833,11 +853,7 @@ getescc(d)
if (tflag)
/* \a undefined in traditional C */
warning(81);
-#ifdef __STDC__
return ('\a');
-#else
- return ('\007');
-#endif
case 'b':
return ('\b');
case 'f':
@@ -852,11 +868,7 @@ getescc(d)
if (tflag)
/* \v undefined in traditional C */
warning(264);
-#ifdef __STDC__
return ('\v');
-#else
- return ('\013');
-#endif
case '8': case '9':
/* bad octal digit %c */
warning(77, c);
@@ -930,7 +942,7 @@ getescc(d)
* # lineno "filename"
*/
static void
-directive()
+directive(void)
{
const char *cp, *fn;
char c, *eptr;
@@ -939,9 +951,10 @@ directive()
static int first = 1;
/* Go to first non-whitespace after # */
- for (cp = yytext + 1; (c = *cp) == ' ' || c == '\t'; cp++) ;
+ for (cp = yytext + 1; (c = *cp) == ' ' || c == '\t'; cp++)
+ continue;
- if (!isdigit(c)) {
+ if (!isdigit((unsigned char)c)) {
error:
/* undefined or invalid # directive */
warning(255);
@@ -952,7 +965,8 @@ directive()
goto error;
if ((c = *(cp = eptr)) != ' ' && c != '\t' && c != '\0')
goto error;
- while ((c = *cp++) == ' ' || c == '\t') ;
+ while ((c = *cp++) == ' ' || c == '\t')
+ continue;
if (c != '\0') {
if (c != '"')
goto error;
@@ -963,11 +977,18 @@ directive()
goto error;
if ((fnl = cp++ - fn) > PATH_MAX)
goto error;
- while ((c = *cp++) == ' ' || c == '\t') ;
+ while ((c = *cp++) == ' ' || c == '\t')
+ continue;
#if 0
if (c != '\0')
warning("extra character(s) after directive");
#endif
+
+ /* empty string means stdin */
+ if (fnl == 0) {
+ fn = "{standard input}";
+ fnl = 16; /* strlen (fn) */
+ }
curr_pos.p_file = fnnalloc(fn, fnl);
/*
* If this is the first directive, the name is the name
@@ -981,13 +1002,17 @@ directive()
}
}
curr_pos.p_line = (int)ln - 1;
- if (curr_pos.p_file == csrc_pos.p_file)
+ curr_pos.p_uniq = 0;
+ if (curr_pos.p_file == csrc_pos.p_file) {
csrc_pos.p_line = (int)ln - 1;
+ csrc_pos.p_uniq = 0;
+ }
}
/*
* Handle lint comments. Following comments are currently understood:
* ARGSUSEDn
+ * BITFIELDTYPE
* CONSTCOND CONSTANTCOND CONSTANTCONDITION
* FALLTHRU FALLTHROUGH
* LINTLIBRARY
@@ -1002,15 +1027,16 @@ directive()
* parsed and a function which handles this comment is called.
*/
static void
-comment()
+comment(void)
{
int c, lc;
static struct {
const char *keywd;
int arg;
- void (*func) __P((int));
+ void (*func)(int);
} keywtab[] = {
{ "ARGSUSED", 1, argsused },
+ { "BITFIELDTYPE", 0, bitfieldtype },
{ "CONSTCOND", 0, constcond },
{ "CONSTANTCOND", 0, constcond },
{ "CONSTANTCONDITION", 0, constcond },
@@ -1034,7 +1060,8 @@ comment()
eoc = 0;
/* Skip white spaces after the start of the comment */
- while ((c = inpc()) != EOF && isspace(c)) ;
+ while ((c = inpc()) != EOF && isspace(c))
+ continue;
/* Read the potential keyword to keywd */
l = 0;
@@ -1100,6 +1127,22 @@ comment()
}
/*
+ * Handle // style comments
+ */
+static void
+slashslashcomment(void)
+{
+ int c;
+
+ if (sflag < 2 && !gflag)
+ /* // comments only supported in C99 */
+ (void)gnuism(312, tflag ? "traditional" : "ANSI");
+
+ while ((c = inpc()) != EOF && c != '\n')
+ continue;
+}
+
+/*
* Clear flags for lint comments LINTED, LONGLONG and CONSTCOND.
* clrwflgs() is called after function definitions and global and
* local declarations and definitions. It is also called between
@@ -1107,8 +1150,9 @@ comment()
* (if, switch, for, while).
*/
void
-clrwflgs()
+clrwflgs(void)
{
+
nowarn = 0;
quadflg = 0;
ccflg = 0;
@@ -1120,7 +1164,7 @@ clrwflgs()
* by the parser are responsible for freeing this buffer.
*/
static int
-string()
+string(void)
{
u_char *s;
int c;
@@ -1151,7 +1195,7 @@ string()
}
static int
-wcstrg()
+wcstrg(void)
{
char *s;
int c, i, n, wi;
@@ -1221,8 +1265,7 @@ wcstrg()
* XXX calls to getsym() should be delayed until decl1*() is called
*/
sym_t *
-getsym(sb)
- sbuf_t *sb;
+getsym(sbuf_t *sb)
{
dinfo_t *di;
char *s;
@@ -1270,7 +1313,7 @@ getsym(sb)
di = dcs;
}
- STRUCT_ASSIGN(sym->s_dpos, curr_pos);
+ UNIQUE_CURR_POS(sym->s_dpos);
if ((sym->s_kind = symtyp) != FLAB)
sym->s_type = gettyp(INT);
@@ -1293,9 +1336,9 @@ getsym(sb)
* back to the symbol table.
*/
void
-rmsym(sym)
- sym_t *sym;
+rmsym(sym_t *sym)
{
+
if ((*sym->s_rlink = sym->s_link) != NULL)
sym->s_link->s_rlink = sym->s_rlink;
sym->s_blklev = -1;
@@ -1307,8 +1350,7 @@ rmsym(sym)
* table.
*/
void
-rmsyms(syms)
- sym_t *syms;
+rmsyms(sym_t *syms)
{
sym_t *sym;
@@ -1326,9 +1368,7 @@ rmsyms(syms)
* Put a symbol into the symbol table
*/
void
-inssym(bl, sym)
- int bl;
- sym_t *sym;
+inssym(int bl, sym_t *sym)
{
int h;
@@ -1348,7 +1388,7 @@ inssym(bl, sym)
* level 0.
*/
void
-cleanup()
+cleanup(void)
{
sym_t *sym, *nsym;
int i;
@@ -1371,8 +1411,7 @@ cleanup()
* Create a new symbol with the name of an existing symbol.
*/
sym_t *
-pushdown(sym)
- sym_t *sym;
+pushdown(sym_t *sym)
{
int h;
sym_t *nsym;
@@ -1382,7 +1421,7 @@ pushdown(sym)
if (sym->s_blklev > blklev)
lerror("pushdown()");
nsym->s_name = sym->s_name;
- STRUCT_ASSIGN(nsym->s_dpos, curr_pos);
+ UNIQUE_CURR_POS(nsym->s_dpos);
nsym->s_kind = sym->s_kind;
nsym->s_blklev = blklev;
@@ -1402,9 +1441,7 @@ pushdown(sym)
* The type of information in yylval is described by tok.
*/
void
-freeyyv(sp, tok)
- void *sp;
- int tok;
+freeyyv(void *sp, int tok)
{
if (tok == T_NAME || tok == T_TYPENAME) {
sbuf_t *sb = *(sbuf_t **)sp;
@@ -1422,5 +1459,5 @@ freeyyv(sp, tok)
lerror("fryylv() 1");
}
free(strg);
- }
+ }
}
diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c
index 525e407..d725de8 100644
--- a/usr.bin/xlint/lint1/tree.c
+++ b/usr.bin/xlint/lint1/tree.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.12 1995/10/02 17:37:57 jpo Exp $ */
+/* $NetBSD: tree.c,v 1.24 2002/01/31 22:30:20 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,8 +31,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: tree.c,v 1.12 1995/10/02 17:37:57 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: tree.c,v 1.24 2002/01/31 22:30:20 tv Exp $");
#endif
#include <stdlib.h>
@@ -42,51 +43,51 @@ static char rcsid[] = "$NetBSD: tree.c,v 1.12 1995/10/02 17:37:57 jpo Exp $";
#include <math.h>
#include "lint1.h"
-#include "y.tab.h"
+#include "cgram.h"
/* Various flags for each operator. */
static mod_t modtab[NOPS];
-static tnode_t *getinode __P((tspec_t, quad_t));
-static void ptrcmpok __P((op_t, tnode_t *, tnode_t *));
-static int asgntypok __P((op_t, int, tnode_t *, tnode_t *));
-static void chkbeop __P((op_t, tnode_t *, tnode_t *));
-static void chkeop2 __P((op_t, int, tnode_t *, tnode_t *));
-static void chkeop1 __P((op_t, int, tnode_t *, tnode_t *));
-static tnode_t *mktnode __P((op_t, type_t *, tnode_t *, tnode_t *));
-static void balance __P((op_t, tnode_t **, tnode_t **));
-static void incompat __P((op_t, tspec_t, tspec_t));
-static void illptrc __P((mod_t *, type_t *, type_t *));
-static void mrgqual __P((type_t **, type_t *, type_t *));
-static int conmemb __P((type_t *));
-static void ptconv __P((int, tspec_t, tspec_t, type_t *, tnode_t *));
-static void iiconv __P((op_t, int, tspec_t, tspec_t, type_t *, tnode_t *));
-static void piconv __P((op_t, tspec_t, type_t *, tnode_t *));
-static void ppconv __P((op_t, tnode_t *, type_t *));
-static tnode_t *bldstr __P((op_t, tnode_t *, tnode_t *));
-static tnode_t *bldincdec __P((op_t, tnode_t *));
-static tnode_t *bldamper __P((tnode_t *, int));
-static tnode_t *bldplmi __P((op_t, tnode_t *, tnode_t *));
-static tnode_t *bldshft __P((op_t, tnode_t *, tnode_t *));
-static tnode_t *bldcol __P((tnode_t *, tnode_t *));
-static tnode_t *bldasgn __P((op_t, tnode_t *, tnode_t *));
-static tnode_t *plength __P((type_t *));
-static tnode_t *fold __P((tnode_t *));
-static tnode_t *foldtst __P((tnode_t *));
-static tnode_t *foldflt __P((tnode_t *));
-static tnode_t *chkfarg __P((type_t *, tnode_t *));
-static tnode_t *parg __P((int, type_t *, tnode_t *));
-static void nulleff __P((tnode_t *));
-static void displexpr __P((tnode_t *, int));
-static void chkaidx __P((tnode_t *, int));
-static void chkcomp __P((op_t, tnode_t *, tnode_t *));
-static void precconf __P((tnode_t *));
+static tnode_t *getinode(tspec_t, int64_t);
+static void ptrcmpok(op_t, tnode_t *, tnode_t *);
+static int asgntypok(op_t, int, tnode_t *, tnode_t *);
+static void chkbeop(op_t, tnode_t *, tnode_t *);
+static void chkeop2(op_t, int, tnode_t *, tnode_t *);
+static void chkeop1(op_t, int, tnode_t *, tnode_t *);
+static tnode_t *mktnode(op_t, type_t *, tnode_t *, tnode_t *);
+static void balance(op_t, tnode_t **, tnode_t **);
+static void incompat(op_t, tspec_t, tspec_t);
+static void illptrc(mod_t *, type_t *, type_t *);
+static void mrgqual(type_t **, type_t *, type_t *);
+static int conmemb(type_t *);
+static void ptconv(int, tspec_t, tspec_t, type_t *, tnode_t *);
+static void iiconv(op_t, int, tspec_t, tspec_t, type_t *, tnode_t *);
+static void piconv(op_t, tspec_t, type_t *, tnode_t *);
+static void ppconv(op_t, tnode_t *, type_t *);
+static tnode_t *bldstr(op_t, tnode_t *, tnode_t *);
+static tnode_t *bldincdec(op_t, tnode_t *);
+static tnode_t *bldamper(tnode_t *, int);
+static tnode_t *bldplmi(op_t, tnode_t *, tnode_t *);
+static tnode_t *bldshft(op_t, tnode_t *, tnode_t *);
+static tnode_t *bldcol(tnode_t *, tnode_t *);
+static tnode_t *bldasgn(op_t, tnode_t *, tnode_t *);
+static tnode_t *plength(type_t *);
+static tnode_t *fold(tnode_t *);
+static tnode_t *foldtst(tnode_t *);
+static tnode_t *foldflt(tnode_t *);
+static tnode_t *chkfarg(type_t *, tnode_t *);
+static tnode_t *parg(int, type_t *, tnode_t *);
+static void nulleff(tnode_t *);
+static void displexpr(tnode_t *, int);
+static void chkaidx(tnode_t *, int);
+static void chkcomp(op_t, tnode_t *, tnode_t *);
+static void precconf(tnode_t *);
/*
* Initialize mods of operators.
*/
void
-initmtab()
+initmtab(void)
{
static struct {
op_t op;
@@ -217,9 +218,7 @@ initmtab()
* This is most often used to change type "T" in type "pointer to T".
*/
type_t *
-incref(tp, t)
- type_t *tp;
- tspec_t t;
+incref(type_t *tp, tspec_t t)
{
type_t *tp2;
@@ -233,9 +232,7 @@ incref(tp, t)
* same for use in expressions
*/
type_t *
-tincref(tp, t)
- type_t *tp;
- tspec_t t;
+tincref(type_t *tp, tspec_t t)
{
type_t *tp2;
@@ -249,9 +246,7 @@ tincref(tp, t)
* Create a node for a constant.
*/
tnode_t *
-getcnode(tp, v)
- type_t *tp;
- val_t *v;
+getcnode(type_t *tp, val_t *v)
{
tnode_t *n;
@@ -270,9 +265,7 @@ getcnode(tp, v)
* Create a node for a integer constant.
*/
static tnode_t *
-getinode(t, q)
- tspec_t t;
- quad_t q;
+getinode(tspec_t t, int64_t q)
{
tnode_t *n;
@@ -290,9 +283,7 @@ getinode(t, q)
* ntok is the token which follows the name.
*/
tnode_t *
-getnnode(sym, ntok)
- sym_t *sym;
- int ntok;
+getnnode(sym_t *sym, int ntok)
{
tnode_t *n;
@@ -338,8 +329,7 @@ getnnode(sym, ntok)
* Create a node for a string.
*/
tnode_t *
-getsnode(strg)
- strg_t *strg;
+getsnode(strg_t *strg)
{
size_t len;
tnode_t *n;
@@ -377,10 +367,7 @@ getsnode(strg)
* member of the struct or union specified by the tn argument.
*/
sym_t *
-strmemb(tn, op, msym)
- tnode_t *tn;
- op_t op;
- sym_t *msym;
+strmemb(tnode_t *tn, op_t op, sym_t *msym)
{
str_t *str;
type_t *tp;
@@ -537,9 +524,7 @@ strmemb(tn, op, msym)
* rn if not NULL, right operand
*/
tnode_t *
-build(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+build(op_t op, tnode_t *ln, tnode_t *rn)
{
mod_t *mp;
tnode_t *ntn;
@@ -565,7 +550,7 @@ build(op, ln, rn)
rn = cconv(rn);
/*
- * Print some warnings for comparisions of unsigned values with
+ * Print some warnings for comparisons of unsigned values with
* constants lower than or equal to null. This must be done
* before promote() because otherwise unsigned char and unsigned
* short would be promoted to int. Also types are tested to be
@@ -670,7 +655,7 @@ build(op, ln, rn)
break;
}
- /* Return if an error occured. */
+ /* Return if an error occurred. */
if (ntn == NULL)
return (NULL);
@@ -717,8 +702,7 @@ build(op, ln, rn)
* Lvalues are converted to rvalues.
*/
tnode_t *
-cconv(tn)
- tnode_t *tn;
+cconv(tnode_t *tn)
{
type_t *tp;
@@ -762,14 +746,12 @@ cconv(tn)
* If the types are ok, typeok() returns 1, otherwise 0.
*/
int
-typeok(op, arg, ln, rn)
- op_t op;
- int arg;
- tnode_t *ln, *rn;
+typeok(op_t op, int arg, tnode_t *ln, tnode_t *rn)
{
mod_t *mp;
- tspec_t lt, rt, lst, rst, olt, ort;
- type_t *ltp, *rtp, *lstp, *rstp;
+ tspec_t lt, rt = NOTSPEC, lst = NOTSPEC, rst = NOTSPEC, olt = NOTSPEC,
+ ort = NOTSPEC;
+ type_t *ltp, *rtp = NULL, *lstp = NULL, *rstp = NULL;
tnode_t *tn;
mp = &modtab[op];
@@ -806,12 +788,14 @@ typeok(op, arg, ln, rn)
* For these operations we need the types before promotion
* and balancing.
*/
- for (tn=ln; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left) ;
+ for (tn=ln; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left)
+ continue;
olt = tn->tn_type->t_tspec;
- for (tn=rn; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left) ;
+ for (tn=rn; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left)
+ continue;
ort = tn->tn_type->t_tspec;
}
-
+
switch (op) {
case POINT:
/*
@@ -978,10 +962,10 @@ typeok(op, arg, ln, rn)
if (!isutyp(rt) && rn->tn_val->v_quad < 0) {
/* negative shift */
warning(121);
- } else if ((u_quad_t)rn->tn_val->v_quad == size(lt)) {
+ } else if ((uint64_t)rn->tn_val->v_quad == size(lt)) {
/* shift equal to size fo object */
warning(267);
- } else if ((u_quad_t)rn->tn_val->v_quad > size(lt)) {
+ } else if ((uint64_t)rn->tn_val->v_quad > size(lt)) {
/* shift greater than size of object */
warning(122);
}
@@ -991,7 +975,7 @@ typeok(op, arg, ln, rn)
case NE:
/*
* Accept some things which are allowed with EQ and NE,
- * but not with ordered comparisions.
+ * but not with ordered comparisons.
*/
if (lt == PTR && ((rt == PTR && rst == VOID) || isityp(rt))) {
if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
@@ -1133,6 +1117,32 @@ typeok(op, arg, ln, rn)
nulleff(ln);
break;
/* LINTED (enumeration values not handled in switch) */
+ case CON:
+ case CASE:
+ case PUSH:
+ case LOAD:
+ case ICALL:
+ case CVT:
+ case CALL:
+ case FSEL:
+ case STRING:
+ case NAME:
+ case LOGOR:
+ case LOGAND:
+ case OR:
+ case XOR:
+ case AND:
+ case MOD:
+ case DIV:
+ case MULT:
+ case UMINUS:
+ case UPLUS:
+ case DEC:
+ case INC:
+ case COMPL:
+ case NOT:
+ case NOOP:
+ break;
}
if (mp->m_badeop &&
@@ -1148,9 +1158,7 @@ typeok(op, arg, ln, rn)
}
static void
-ptrcmpok(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+ptrcmpok(op_t op, tnode_t *ln, tnode_t *rn)
{
type_t *ltp, *rtp;
tspec_t lt, rt;
@@ -1164,7 +1172,7 @@ ptrcmpok(op, ln, rn)
/* (void *)0 already handled in typeok() */
*(lt == FUNC ? &lts : &rts) = "function pointer";
*(lt == VOID ? &lts : &rts) = "'void *'";
- /* ANSI C forbids comparision of %s with %s */
+ /* ANSI C forbids comparison of %s with %s */
warning(274, lts, rts);
}
return;
@@ -1188,13 +1196,10 @@ ptrcmpok(op, ln, rn)
* If the types are (almost) compatible, 1 is returned, otherwise 0.
*/
static int
-asgntypok(op, arg, ln, rn)
- op_t op;
- int arg;
- tnode_t *ln, *rn;
+asgntypok(op_t op, int arg, tnode_t *ln, tnode_t *rn)
{
- tspec_t lt, rt, lst, rst;
- type_t *ltp, *rtp, *lstp, *rstp;
+ tspec_t lt, rt, lst = NOTSPEC, rst = NOTSPEC;
+ type_t *ltp, *rtp, *lstp = NULL, *rstp = NULL;
mod_t *mp;
const char *lts, *rts;
@@ -1329,9 +1334,7 @@ asgntypok(op, arg, ln, rn)
* enum type, is applied to an enum type.
*/
static void
-chkbeop(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+chkbeop(op_t op, tnode_t *ln, tnode_t *rn)
{
mod_t *mp;
@@ -1364,10 +1367,7 @@ chkbeop(op, ln, rn)
* Prints a warning if an operator is applied to two different enum types.
*/
static void
-chkeop2(op, arg, ln, rn)
- op_t op;
- int arg;
- tnode_t *ln, *rn;
+chkeop2(op_t op, int arg, tnode_t *ln, tnode_t *rn)
{
mod_t *mp;
@@ -1395,7 +1395,7 @@ chkeop2(op, arg, ln, rn)
#if 0
} else if (mp->m_comp && op != EQ && op != NE) {
if (eflag)
- /* dubious comparisions of enums */
+ /* dubious comparisons of enums */
warning(243, mp->m_name);
#endif
}
@@ -1406,11 +1406,9 @@ chkeop2(op, arg, ln, rn)
* types.
*/
static void
-chkeop1(op, arg, ln, rn)
- op_t op;
- int arg;
- tnode_t *ln, *rn;
+chkeop1(op_t op, int arg, tnode_t *ln, tnode_t *rn)
{
+
if (!eflag)
return;
@@ -1448,10 +1446,7 @@ chkeop1(op, arg, ln, rn)
* Build and initialize a new node.
*/
static tnode_t *
-mktnode(op, type, ln, rn)
- op_t op;
- type_t *type;
- tnode_t *ln, *rn;
+mktnode(op_t op, type_t *type, tnode_t *ln, tnode_t *rn)
{
tnode_t *ntn;
tspec_t t;
@@ -1484,10 +1479,7 @@ mktnode(op, type, ln, rn)
* float to double.
*/
tnode_t *
-promote(op, farg, tn)
- op_t op;
- int farg;
- tnode_t *tn;
+promote(op_t op, int farg, tnode_t *tn)
{
tspec_t t;
type_t *ntp;
@@ -1562,9 +1554,7 @@ promote(op, farg, tn)
* type. This is done in different ways for traditional C and ANIS C.
*/
static void
-balance(op, lnp, rnp)
- op_t op;
- tnode_t **lnp, **rnp;
+balance(op_t op, tnode_t **lnp, tnode_t **rnp)
{
tspec_t lt, rt, t;
int i, u;
@@ -1639,14 +1629,10 @@ balance(op, lnp, rnp)
* If op is FARG, arg is the number of the argument (used for warnings).
*/
tnode_t *
-convert(op, arg, tp, tn)
- op_t op;
- int arg;
- type_t *tp;
- tnode_t *tn;
+convert(op_t op, int arg, type_t *tp, tnode_t *tn)
{
tnode_t *ntn;
- tspec_t nt, ot, ost;
+ tspec_t nt, ot, ost = NOTSPEC;
if (tn->tn_lvalue)
lerror("convert() 1");
@@ -1692,11 +1678,7 @@ convert(op, arg, tp, tn)
* in asgntypok().
*/
static void
-ptconv(arg, nt, ot, tp, tn)
- int arg;
- tspec_t nt, ot;
- type_t *tp;
- tnode_t *tn;
+ptconv(int arg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
{
tnode_t *ptn;
@@ -1748,12 +1730,7 @@ ptconv(arg, nt, ot, tp, tn)
*/
/* ARGSUSED */
static void
-iiconv(op, arg, nt, ot, tp, tn)
- op_t op;
- int arg;
- tspec_t nt, ot;
- type_t *tp;
- tnode_t *tn;
+iiconv(op_t op, int arg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
{
if (tn->tn_op == CON)
return;
@@ -1784,7 +1761,7 @@ iiconv(op, arg, nt, ot, tp, tn)
} else {
warning(132, tyname(tn->tn_type));
}
- }
+ }
}
}
@@ -1792,12 +1769,9 @@ iiconv(op, arg, nt, ot, tp, tn)
* Print warnings for dubious conversions of pointer to integer.
*/
static void
-piconv(op, nt, tp, tn)
- op_t op;
- tspec_t nt;
- type_t *tp;
- tnode_t *tn;
+piconv(op_t op, tspec_t nt, type_t *tp, tnode_t *tn)
{
+
if (tn->tn_op == CON)
return;
@@ -1821,10 +1795,7 @@ piconv(op, nt, tp, tn)
* Print warnings for questionable pointer conversions.
*/
static void
-ppconv(op, tn, tp)
- op_t op;
- tnode_t *tn;
- type_t *tp;
+ppconv(op_t op, tnode_t *tn, type_t *tp)
{
tspec_t nt, ot;
const char *nts, *ots;
@@ -1855,7 +1826,7 @@ ppconv(op, tn, tp)
warning(229);
return;
}
-
+
if (getbound(tp->t_subt) > getbound(tn->tn_type->t_subt)) {
if (hflag)
/* possible pointer alignment problem */
@@ -1881,16 +1852,12 @@ ppconv(op, tn, tp)
* v old constant
*/
void
-cvtcon(op, arg, tp, nv, v)
- op_t op;
- int arg;
- type_t *tp;
- val_t *nv, *v;
+cvtcon(op_t op, int arg, type_t *tp, val_t *nv, val_t *v)
{
tspec_t ot, nt;
- ldbl_t max, min;
+ ldbl_t max = 0.0, min = 0.0;
int sz, rchk;
- quad_t xmask, xmsk1;
+ int64_t xmask, xmsk1;
int osz, nsz;
ot = v->v_tspec;
@@ -1921,7 +1888,7 @@ cvtcon(op, arg, tp, nv, v)
case QUAD:
max = QUAD_MAX; min = QUAD_MIN; break;
case UQUAD:
- max = (u_quad_t)UQUAD_MAX; min = 0; break;
+ max = (uint64_t)UQUAD_MAX; min = 0; break;
case FLOAT:
max = FLT_MAX; min = -FLT_MAX; break;
case DOUBLE:
@@ -1954,18 +1921,18 @@ cvtcon(op, arg, tp, nv, v)
nv->v_ldbl = v->v_ldbl;
} else {
nv->v_quad = (nt == PTR || isutyp(nt)) ?
- (u_quad_t)v->v_ldbl : (quad_t)v->v_ldbl;
+ (uint64_t)v->v_ldbl : (int64_t)v->v_ldbl;
}
} else {
if (nt == FLOAT) {
nv->v_ldbl = (ot == PTR || isutyp(ot)) ?
- (float)(u_quad_t)v->v_quad : (float)v->v_quad;
+ (float)(uint64_t)v->v_quad : (float)v->v_quad;
} else if (nt == DOUBLE) {
nv->v_ldbl = (ot == PTR || isutyp(ot)) ?
- (double)(u_quad_t)v->v_quad : (double)v->v_quad;
+ (double)(uint64_t)v->v_quad : (double)v->v_quad;
} else if (nt == LDOUBLE) {
nv->v_ldbl = (ot == PTR || isutyp(ot)) ?
- (ldbl_t)(u_quad_t)v->v_quad : (ldbl_t)v->v_quad;
+ (ldbl_t)(uint64_t)v->v_quad : (ldbl_t)v->v_quad;
} else {
rchk = 1; /* Check for lost precision. */
nv->v_quad = v->v_quad;
@@ -1987,7 +1954,7 @@ cvtcon(op, arg, tp, nv, v)
sz = tp->t_isfield ? tp->t_flen : size(nt);
nv->v_quad = xsign(nv->v_quad, nt, sz);
}
-
+
if (rchk && op != CVT) {
osz = size(ot);
nsz = tp->t_isfield ? tp->t_flen : size(nt);
@@ -2114,9 +2081,7 @@ cvtcon(op, arg, tp, nv, v)
* Prints a appropriate warning.
*/
static void
-incompat(op, lt, rt)
- op_t op;
- tspec_t lt, rt;
+incompat(op_t op, tspec_t lt, tspec_t rt)
{
mod_t *mp;
@@ -2148,9 +2113,7 @@ incompat(op, lt, rt)
* Print an appropriate warning.
*/
static void
-illptrc(mp, ltp, rtp)
- mod_t *mp;
- type_t *ltp, *rtp;
+illptrc(mod_t *mp, type_t *ltp, type_t *rtp)
{
tspec_t lt, rt;
@@ -2184,9 +2147,9 @@ illptrc(mp, ltp, rtp)
* of tp1->t_subt and tp2->t_subt.
*/
static void
-mrgqual(tpp, tp1, tp2)
- type_t **tpp, *tp1, *tp2;
+mrgqual(type_t **tpp, type_t *tp1, type_t *tp2)
{
+
if ((*tpp)->t_tspec != PTR ||
tp1->t_tspec != PTR || tp2->t_tspec != PTR) {
lerror("mrgqual()");
@@ -2212,8 +2175,7 @@ mrgqual(tpp, tp1, tp2)
* (maybe recursively).
*/
static int
-conmemb(tp)
- type_t *tp;
+conmemb(type_t *tp)
{
sym_t *m;
tspec_t t;
@@ -2233,8 +2195,7 @@ conmemb(tp)
}
const char *
-tyname(tp)
- type_t *tp;
+tyname(type_t *tp)
{
tspec_t t;
const char *s;
@@ -2273,9 +2234,7 @@ tyname(tp)
* Create a new node for one of the operators POINT and ARROW.
*/
static tnode_t *
-bldstr(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+bldstr(op_t op, tnode_t *ln, tnode_t *rn)
{
tnode_t *ntn, *ctn;
int nolval;
@@ -2327,9 +2286,7 @@ bldstr(op, ln, rn)
* Create a node for INCAFT, INCBEF, DECAFT and DECBEF.
*/
static tnode_t *
-bldincdec(op, ln)
- op_t op;
- tnode_t *ln;
+bldincdec(op_t op, tnode_t *ln)
{
tnode_t *cn, *ntn;
@@ -2339,7 +2296,7 @@ bldincdec(op, ln)
if (ln->tn_type->t_tspec == PTR) {
cn = plength(ln->tn_type);
} else {
- cn = getinode(INT, (quad_t)1);
+ cn = getinode(INT, (int64_t)1);
}
ntn = mktnode(op, ln->tn_type, ln, cn);
@@ -2350,13 +2307,11 @@ bldincdec(op, ln)
* Create a tree node for the & operator
*/
static tnode_t *
-bldamper(tn, noign)
- tnode_t *tn;
- int noign;
+bldamper(tnode_t *tn, int noign)
{
tnode_t *ntn;
tspec_t t;
-
+
if (!noign && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) {
/* & before array or function: ignored */
if (tflag)
@@ -2370,7 +2325,7 @@ bldamper(tn, noign)
tn->tn_left->tn_type->t_subt == tn->tn_type) {
return (tn->tn_left);
}
-
+
ntn = mktnode(AMPER, tincref(tn->tn_type, PTR), tn, NULL);
return (ntn);
@@ -2380,9 +2335,7 @@ bldamper(tn, noign)
* Create a node for operators PLUS and MINUS.
*/
static tnode_t *
-bldplmi(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+bldplmi(op_t op, tnode_t *ln, tnode_t *rn)
{
tnode_t *ntn, *ctn;
type_t *tp;
@@ -2435,9 +2388,7 @@ bldplmi(op, ln, rn)
* Create a node for operators SHL and SHR.
*/
static tnode_t *
-bldshft(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+bldshft(op_t op, tnode_t *ln, tnode_t *rn)
{
tspec_t t;
tnode_t *ntn;
@@ -2452,8 +2403,7 @@ bldshft(op, ln, rn)
* Create a node for COLON.
*/
static tnode_t *
-bldcol(ln, rn)
- tnode_t *ln, *rn;
+bldcol(tnode_t *ln, tnode_t *rn)
{
tspec_t lt, rt, pdt;
type_t *rtp;
@@ -2531,9 +2481,7 @@ bldcol(ln, rn)
* Create a node for an assignment operator (both = and op= ).
*/
static tnode_t *
-bldasgn(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+bldasgn(op_t op, tnode_t *ln, tnode_t *rn)
{
tspec_t lt, rt;
tnode_t *ntn, *ctn;
@@ -2594,8 +2542,7 @@ bldasgn(op, ln, rn)
* Get length of type tp->t_subt.
*/
static tnode_t *
-plength(tp)
- type_t *tp;
+plength(type_t *tp)
{
int elem, elsz;
tspec_t st;
@@ -2657,39 +2604,28 @@ plength(tp)
st = INT;
#endif
- return (getinode(st, (quad_t)(elem * elsz / CHAR_BIT)));
+ return (getinode(st, (int64_t)(elem * elsz / CHAR_BIT)));
}
-#ifdef XXX_BROKEN_GCC
-static int
-quad_t_eq(x, y)
- quad_t x, y;
-{
- return (x == y);
-}
-
-static int
-u_quad_t_eq(x, y)
- u_quad_t x, y;
-{
- return (x == y);
-}
-#endif
-
+/*
+ * XXX
+ * Note: There appear to be a number of bugs in detecting overflow in
+ * this function. An audit and a set of proper regression tests are needed.
+ * --Perry Metzger, Nov. 16, 2001
+ */
/*
* Do only as much as necessary to compute constant expressions.
* Called only if the operator allows folding and (both) operands
* are constants.
*/
static tnode_t *
-fold(tn)
- tnode_t *tn;
+fold(tnode_t *tn)
{
val_t *v;
tspec_t t;
int utyp, ovfl;
- quad_t sl, sr, q, mask;
- u_quad_t ul, ur;
+ int64_t sl, sr = 0, q = 0, mask;
+ uint64_t ul, ur = 0;
tnode_t *cn;
v = xcalloc(1, sizeof (val_t));
@@ -2700,6 +2636,7 @@ fold(tn)
if (modtab[tn->tn_op].m_binary)
ur = sr = tn->tn_right->tn_val->v_quad;
+ mask = qlmasks[size(t)];
ovfl = 0;
switch (tn->tn_op) {
@@ -2715,9 +2652,17 @@ fold(tn)
q = ~sl;
break;
case MULT:
- q = utyp ? ul * ur : sl * sr;
- if (msb(q, t, -1) != (msb(sl, t, -1) ^ msb(sr, t, -1)))
- ovfl = 1;
+ if (utyp) {
+ q = ul * ur;
+ if (q != (q & mask))
+ ovfl = 1;
+ else if ((ul != 0) && ((q / ul) != ur))
+ ovfl = 1;
+ } else {
+ q = sl * sr;
+ if (msb(q, t, -1) != (msb(sl, t, -1) ^ msb(sr, t, -1)))
+ ovfl = 1;
+ }
break;
case DIV:
if (sr == 0) {
@@ -2762,7 +2707,7 @@ fold(tn)
break;
case SHR:
/*
- * The sign must be explizitly extended because
+ * The sign must be explicitly extended because
* shifts of signed values are implementation dependent.
*/
q = ul >> sr;
@@ -2781,11 +2726,7 @@ fold(tn)
q = utyp ? ul > ur : sl > sr;
break;
case EQ:
-#ifdef XXX_BROKEN_GCC
- q = utyp ? u_quad_t_eq(ul, ur) : quad_t_eq(sl, sr);
-#else
q = utyp ? ul == ur : sl == sr;
-#endif
break;
case NE:
q = utyp ? ul != ur : sl != sr;
@@ -2803,10 +2744,8 @@ fold(tn)
lerror("fold() 5");
}
- mask = qlmasks[size(t)];
-
/* XXX does not work for quads. */
- if (ovfl || ((q | mask) != ~(u_quad_t)0 && (q & ~mask) != 0)) {
+ if (ovfl || ((q | mask) != ~(uint64_t)0 && (q & ~mask) != 0)) {
if (hflag)
/* integer overflow detected, op %s */
warning(141, modtab[tn->tn_op].m_name);
@@ -2819,23 +2758,13 @@ fold(tn)
return (cn);
}
-#ifdef XXX_BROKEN_GCC
-int
-ldbl_t_neq(x, y)
- ldbl_t x, y;
-{
- return (x != y);
-}
-#endif
-
/*
* Same for operators whose operands are compared with 0 (test context).
*/
static tnode_t *
-foldtst(tn)
- tnode_t *tn;
+foldtst(tnode_t *tn)
{
- int l, r;
+ int l, r = 0;
val_t *v;
v = xcalloc(1, sizeof (val_t));
@@ -2844,22 +2773,14 @@ foldtst(tn)
lerror("foldtst() 1");
if (isftyp(tn->tn_left->tn_type->t_tspec)) {
-#ifdef XXX_BROKEN_GCC
- l = ldbl_t_neq(tn->tn_left->tn_val->v_ldbl, 0.0);
-#else
l = tn->tn_left->tn_val->v_ldbl != 0.0;
-#endif
} else {
l = tn->tn_left->tn_val->v_quad != 0;
}
if (modtab[tn->tn_op].m_binary) {
if (isftyp(tn->tn_right->tn_type->t_tspec)) {
-#ifdef XXX_BROKEN_GCC
- r = ldbl_t_neq(tn->tn_right->tn_val->v_ldbl, 0.0);
-#else
r = tn->tn_right->tn_val->v_ldbl != 0.0;
-#endif
} else {
r = tn->tn_right->tn_val->v_quad != 0;
}
@@ -2889,12 +2810,11 @@ foldtst(tn)
* Same for operands with floating point type.
*/
static tnode_t *
-foldflt(tn)
- tnode_t *tn;
+foldflt(tnode_t *tn)
{
val_t *v;
tspec_t t;
- ldbl_t l, r;
+ ldbl_t l, r = 0;
v = xcalloc(1, sizeof (val_t));
v->v_tspec = t = tn->tn_type->t_tspec;
@@ -2966,7 +2886,7 @@ foldflt(tn)
if (isnan((double)v->v_ldbl))
lerror("foldflt() 5");
- if (isinf((double)v->v_ldbl) ||
+ if (!finite((double)v->v_ldbl) ||
(t == FLOAT &&
(v->v_ldbl > FLT_MAX || v->v_ldbl < -FLT_MAX)) ||
(t == DOUBLE &&
@@ -2989,8 +2909,7 @@ foldflt(tn)
* Create a constant node for sizeof.
*/
tnode_t *
-bldszof(tp)
- type_t *tp;
+bldszof(type_t *tp)
{
int elem, elsz;
tspec_t st;
@@ -3050,16 +2969,14 @@ bldszof(tp)
st = UINT;
#endif
- return (getinode(st, (quad_t)(elem * elsz / CHAR_BIT)));
+ return (getinode(st, (int64_t)(elem * elsz / CHAR_BIT)));
}
/*
* Type casts.
*/
tnode_t *
-cast(tn, tp)
- tnode_t *tn;
- type_t *tp;
+cast(tnode_t *tn, type_t *tp)
{
tspec_t nt, ot;
@@ -3118,8 +3035,7 @@ cast(tn, tp)
* in funcarg() we have no information about expected argument types.
*/
tnode_t *
-funcarg(args, arg)
- tnode_t *args, *arg;
+funcarg(tnode_t *args, tnode_t *arg)
{
tnode_t *ntn;
@@ -3129,7 +3045,7 @@ funcarg(args, arg)
* will not change.
*/
if (arg == NULL)
- arg = getinode(INT, (quad_t)0);
+ arg = getinode(INT, (int64_t)0);
ntn = mktnode(PUSH, arg->tn_type, arg, args);
@@ -3141,8 +3057,7 @@ funcarg(args, arg)
* function arguments and insert conversions, if necessary.
*/
tnode_t *
-funccall(func, args)
- tnode_t *func, *args;
+funccall(tnode_t *func, tnode_t *args)
{
tnode_t *ntn;
op_t fcop;
@@ -3181,9 +3096,7 @@ funccall(func, args)
* if necessary.
*/
static tnode_t *
-chkfarg(ftp, args)
- type_t *ftp; /* type of called function */
- tnode_t *args; /* arguments */
+chkfarg(type_t *ftp, tnode_t *args)
{
tnode_t *arg;
sym_t *asym;
@@ -3206,14 +3119,15 @@ chkfarg(ftp, args)
error(150, narg, narg > 1 ? "s" : "", npar);
asym = NULL;
}
-
+
for (n = 1; n <= narg; n++) {
/*
* The rightmost argument is at the top of the argument
* subtree.
*/
- for (i = narg, arg = args; i > n; i--, arg = arg->tn_right) ;
+ for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
+ continue;
/* some things which are always not allowd */
if ((at = arg->tn_left->tn_type->t_tspec) == VOID) {
@@ -3255,10 +3169,9 @@ chkfarg(ftp, args)
* the type of the parameter.
*/
static tnode_t *
-parg(n, tp, tn)
- int n; /* pos of arg */
- type_t *tp; /* expected type (from prototype) */
- tnode_t *tn; /* argument */
+parg( int n, /* pos of arg */
+ type_t *tp, /* expected type (from prototype) */
+ tnode_t *tn) /* argument */
{
tnode_t *ln;
int warn;
@@ -3281,8 +3194,7 @@ parg(n, tp, tn)
* type, an error message is printed.
*/
val_t *
-constant(tn)
- tnode_t *tn;
+constant(tnode_t *tn)
{
val_t *v;
@@ -3334,10 +3246,9 @@ constant(tn)
* for the expression.
*/
void
-expr(tn, vctx, tctx)
- tnode_t *tn;
- int vctx, tctx;
+expr(tnode_t *tn, int vctx, int tctx)
{
+
if (tn == NULL && nerr == 0)
lerror("expr() 1");
@@ -3376,9 +3287,9 @@ expr(tn, vctx, tctx)
}
static void
-nulleff(tn)
- tnode_t *tn;
+nulleff(tnode_t *tn)
{
+
if (!hflag)
return;
@@ -3397,7 +3308,7 @@ nulleff(tn)
* operands has a side effect
*/
tn = tn->tn_right;
- } else if (tn->tn_op == COLON) {
+ } else if (tn->tn_op == COLON || tn->tn_op == COMMA) {
/*
* : has a side effect if at least one of its operands
* has a side effect
@@ -3423,11 +3334,9 @@ nulleff(tn)
* only used for debugging
*/
static void
-displexpr(tn, offs)
- tnode_t *tn;
- int offs;
+displexpr(tnode_t *tn, int offs)
{
- u_quad_t uq;
+ uint64_t uq;
if (tn == NULL) {
(void)printf("%*s%s\n", offs, "", "NULL");
@@ -3481,9 +3390,8 @@ displexpr(tn, offs)
*/
/* ARGSUSED */
void
-chkmisc(tn, vctx, tctx, eqwarn, fcall, rvdisc, szof)
- tnode_t *tn;
- int vctx, tctx, eqwarn, fcall, rvdisc, szof;
+chkmisc(tnode_t *tn, int vctx, int tctx, int eqwarn, int fcall, int rvdisc,
+ int szof)
{
tnode_t *ln, *rn;
mod_t *mp;
@@ -3576,6 +3484,44 @@ chkmisc(tn, vctx, tctx, eqwarn, fcall, rvdisc, szof)
case STRING:
return;
/* LINTED (enumeration values not handled in switch) */
+ case OR:
+ case XOR:
+ case NE:
+ case GE:
+ case GT:
+ case LE:
+ case LT:
+ case SHR:
+ case SHL:
+ case MINUS:
+ case PLUS:
+ case MOD:
+ case DIV:
+ case MULT:
+ case STAR:
+ case UMINUS:
+ case UPLUS:
+ case DEC:
+ case INC:
+ case COMPL:
+ case NOT:
+ case POINT:
+ case ARROW:
+ case NOOP:
+ case AND:
+ case FARG:
+ case CASE:
+ case INIT:
+ case RETURN:
+ case ICALL:
+ case CVT:
+ case COMMA:
+ case FSEL:
+ case COLON:
+ case QUEST:
+ case LOGOR:
+ case LOGAND:
+ break;
}
cvctx = mp->m_vctx;
@@ -3603,6 +3549,9 @@ chkmisc(tn, vctx, tctx, eqwarn, fcall, rvdisc, szof)
case COLON:
chkmisc(rn, cvctx, ctctx, mp->m_eqwarn, 0, 0, szof);
break;
+ case COMMA:
+ chkmisc(rn, vctx, tctx, mp->m_eqwarn, 0, 0, szof);
+ break;
default:
if (mp->m_binary)
chkmisc(rn, 1, 0, mp->m_eqwarn, 0, 0, szof);
@@ -3618,14 +3567,12 @@ chkmisc(tn, vctx, tctx, eqwarn, fcall, rvdisc, szof)
* after the array.
*/
static void
-chkaidx(tn, amper)
- tnode_t *tn;
- int amper;
+chkaidx(tnode_t *tn, int amper)
{
int dim;
tnode_t *ln, *rn;
int elsz;
- quad_t con;
+ int64_t con;
ln = tn->tn_left;
rn = tn->tn_right;
@@ -3641,7 +3588,7 @@ chkaidx(tn, amper)
return;
if (ln->tn_left->tn_type->t_tspec != ARRAY)
return;
-
+
/*
* For incomplete array types, we can print a warning only if
* the index is negative.
@@ -3656,7 +3603,7 @@ chkaidx(tn, amper)
/* Change the unit of the index from bytes to element size. */
if (isutyp(rn->tn_type->t_tspec)) {
- con = (u_quad_t)rn->tn_val->v_quad / elsz;
+ con = (uint64_t)rn->tn_val->v_quad / elsz;
} else {
con = rn->tn_val->v_quad / elsz;
}
@@ -3666,19 +3613,17 @@ chkaidx(tn, amper)
if (!isutyp(rn->tn_type->t_tspec) && con < 0) {
/* array subscript cannot be negative: %ld */
warning(167, (long)con);
- } else if (dim > 0 && (u_quad_t)con >= dim) {
+ } else if (dim > 0 && (uint64_t)con >= dim) {
/* array subscript cannot be > %d: %ld */
warning(168, dim - 1, (long)con);
}
}
/*
- * Check for ordered comparisions of unsigned values with 0.
+ * Check for ordered comparisons of unsigned values with 0.
*/
static void
-chkcomp(op, ln, rn)
- op_t op;
- tnode_t *ln, *rn;
+chkcomp(op_t op, tnode_t *ln, tnode_t *rn)
{
tspec_t lt, rt;
mod_t *mp;
@@ -3696,25 +3641,25 @@ chkcomp(op, ln, rn)
if ((hflag || pflag) && lt == CHAR && rn->tn_op == CON &&
(rn->tn_val->v_quad < 0 ||
rn->tn_val->v_quad > ~(~0 << (CHAR_BIT - 1)))) {
- /* nonportable character comparision, op %s */
+ /* nonportable character comparison, op %s */
warning(230, mp->m_name);
return;
}
if ((hflag || pflag) && rt == CHAR && ln->tn_op == CON &&
(ln->tn_val->v_quad < 0 ||
ln->tn_val->v_quad > ~(~0 << (CHAR_BIT - 1)))) {
- /* nonportable character comparision, op %s */
+ /* nonportable character comparison, op %s */
warning(230, mp->m_name);
return;
}
if (isutyp(lt) && !isutyp(rt) &&
rn->tn_op == CON && rn->tn_val->v_quad <= 0) {
if (rn->tn_val->v_quad < 0) {
- /* comparision of %s with %s, op %s */
+ /* comparison of %s with %s, op %s */
warning(162, tyname(ln->tn_type), "negative constant",
mp->m_name);
} else if (op == LT || op == GE || (hflag && op == LE)) {
- /* comparision of %s with %s, op %s */
+ /* comparison of %s with %s, op %s */
warning(162, tyname(ln->tn_type), "0", mp->m_name);
}
return;
@@ -3722,11 +3667,11 @@ chkcomp(op, ln, rn)
if (isutyp(rt) && !isutyp(lt) &&
ln->tn_op == CON && ln->tn_val->v_quad <= 0) {
if (ln->tn_val->v_quad < 0) {
- /* comparision of %s with %s, op %s */
+ /* comparison of %s with %s, op %s */
warning(162, "negative constant", tyname(rn->tn_type),
mp->m_name);
} else if (op == GT || op == LE || (hflag && op == GE)) {
- /* comparision of %s with %s, op %s */
+ /* comparison of %s with %s, op %s */
warning(162, "0", tyname(rn->tn_type), mp->m_name);
}
return;
@@ -3747,10 +3692,7 @@ chkcomp(op, ln, rn)
* representation (including width).
*/
int
-conaddr(tn, symp, offsp)
- tnode_t *tn;
- sym_t **symp;
- ptrdiff_t *offsp;
+conaddr(tnode_t *tn, sym_t **symp, ptrdiff_t *offsp)
{
sym_t *sym;
ptrdiff_t offs1, offs2;
@@ -3812,8 +3754,7 @@ conaddr(tn, symp, offsp)
* Concatenate two string constants.
*/
strg_t *
-catstrg(strg1, strg2)
- strg_t *strg1, *strg2;
+catstrg(strg_t *strg1, strg_t *strg2)
{
size_t len1, len2, len;
@@ -3849,12 +3790,11 @@ catstrg(strg1, strg2)
* expressions are already folded.
*/
static void
-precconf(tn)
- tnode_t *tn;
+precconf(tnode_t *tn)
{
tnode_t *ln, *rn;
- op_t lop, rop;
- int lparn, rparn;
+ op_t lop, rop = NOOP;
+ int lparn, rparn = 0;
mod_t *mp;
int warn;
@@ -3914,6 +3854,61 @@ precconf(tn)
}
break;
/* LINTED (enumeration values not handled in switch) */
+ case DECAFT:
+ case XORASS:
+ case SHLASS:
+ case NOOP:
+ case ARROW:
+ case ORASS:
+ case POINT:
+ case NAME:
+ case NOT:
+ case COMPL:
+ case CON:
+ case INC:
+ case STRING:
+ case DEC:
+ case INCBEF:
+ case DECBEF:
+ case INCAFT:
+ case FSEL:
+ case CALL:
+ case COMMA:
+ case CVT:
+ case ICALL:
+ case LOAD:
+ case PUSH:
+ case RETURN:
+ case INIT:
+ case CASE:
+ case FARG:
+ case SUBASS:
+ case ADDASS:
+ case MODASS:
+ case DIVASS:
+ case MULASS:
+ case ASSIGN:
+ case COLON:
+ case QUEST:
+ case LOGAND:
+ case NE:
+ case EQ:
+ case GE:
+ case GT:
+ case LE:
+ case LT:
+ case MINUS:
+ case PLUS:
+ case MOD:
+ case DIV:
+ case MULT:
+ case AMPER:
+ case STAR:
+ case UMINUS:
+ case SHRASS:
+ case UPLUS:
+ case ANDASS:
+ break;
}
if (warn) {
diff --git a/usr.bin/xlint/lint2/Makefile b/usr.bin/xlint/lint2/Makefile
index 0e7d405..60f7886 100644
--- a/usr.bin/xlint/lint2/Makefile
+++ b/usr.bin/xlint/lint2/Makefile
@@ -1,13 +1,14 @@
-# $NetBSD: Makefile,v 1.2 1995/07/03 21:24:39 cgd Exp $
+# $NetBSD: Makefile,v 1.12 2002/01/18 20:39:32 thorpej Exp $
-.PATH: ${.CURDIR}/../lint1
-
-PROG= lint2
-SRCS= main2.c hash.c read.c mem.c mem2.c chk.c msg.c emit.c emit2.c
-NOMAN=
-CFLAGS+=-I${.CURDIR}/../lint1
-LINTFLAGS=-abehrz
-
-BINDIR= /usr/libexec
+PROG= lint2
+SRCS= main2.c hash.c read.c mem.c mem2.c chk.c msg.c emit.c emit2.c \
+ inittyp.c
+NOMAN= # defined
+LINTFLAGS= -abehrz
+WFORMAT=1 # hopeless
+BINDIR= /usr/libexec
+.ifndef HOSTPROG
.include <bsd.prog.mk>
+.endif
+
diff --git a/usr.bin/xlint/lint2/chk.c b/usr.bin/xlint/lint2/chk.c
index 0aac852..46923f9 100644
--- a/usr.bin/xlint/lint2/chk.c
+++ b/usr.bin/xlint/lint2/chk.c
@@ -1,6 +1,7 @@
-/* $NetBSD: chk.c,v 1.2 1995/07/03 21:24:42 cgd Exp $ */
+/* $NetBSD: chk.c,v 1.15 2002/01/21 19:49:52 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -31,138 +32,44 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: chk.c,v 1.2 1995/07/03 21:24:42 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: chk.c,v 1.15 2002/01/21 19:49:52 tv Exp $");
#endif
-#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
-#include <err.h>
+#include <stdlib.h>
#include "lint2.h"
-/* various type information */
-ttab_t ttab[NTSPEC];
-
-
-static void chkund __P((hte_t *));
-static void chkdnu __P((hte_t *));
-static void chkdnud __P((hte_t *));
-static void chkmd __P((hte_t *));
-static void chkvtui __P((hte_t *, sym_t *, sym_t *));
-static void chkvtdi __P((hte_t *, sym_t *, sym_t *));
-static void chkfaui __P((hte_t *, sym_t *, sym_t *));
-static void chkau __P((hte_t *, int, sym_t *, sym_t *, pos_t *,
- fcall_t *, fcall_t *, type_t *, type_t *));
-static void chkrvu __P((hte_t *, sym_t *));
-static void chkadecl __P((hte_t *, sym_t *, sym_t *));
-static void printflike __P((hte_t *,fcall_t *, int,
- const char *, type_t **));
-static void scanflike __P((hte_t *, fcall_t *, int,
- const char *, type_t **));
-static void badfmt __P((hte_t *, fcall_t *));
-static void inconarg __P((hte_t *, fcall_t *, int));
-static void tofewarg __P((hte_t *, fcall_t *));
-static void tomanyarg __P((hte_t *, fcall_t *));
-static int eqtype __P((type_t *, type_t *, int, int, int, int *));
-static int eqargs __P((type_t *, type_t *, int *));
-static int mnoarg __P((type_t *, int *));
-
-
-void
-inittyp()
-{
- int i;
- static struct {
- tspec_t it_tspec;
- ttab_t it_ttab;
- } ittab[] = {
- { SIGNED, { 0, 0,
- SIGNED, UNSIGN,
- 0, 0, 0, 0, 0, "signed" } },
- { UNSIGN, { 0, 0,
- SIGNED, UNSIGN,
- 0, 0, 0, 0, 0, "unsigned" } },
- { CHAR, { CHAR_BIT, CHAR_BIT,
- SCHAR, UCHAR,
- 1, 0, 0, 1, 1, "char" } },
- { SCHAR, { CHAR_BIT, CHAR_BIT,
- SCHAR, UCHAR,
- 1, 0, 0, 1, 1, "signed char" } },
- { UCHAR, { CHAR_BIT, CHAR_BIT,
- SCHAR, UCHAR,
- 1, 1, 0, 1, 1, "unsigned char" } },
- { SHORT, { sizeof (short) * CHAR_BIT, 2 * CHAR_BIT,
- SHORT, USHORT,
- 1, 0, 0, 1, 1, "short" } },
- { USHORT, { sizeof (u_short) * CHAR_BIT, 2 * CHAR_BIT,
- SHORT, USHORT,
- 1, 1, 0, 1, 1, "unsigned short" } },
- { INT, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
- INT, UINT,
- 1, 0, 0, 1, 1, "int" } },
- { UINT, { sizeof (u_int) * CHAR_BIT, 3 * CHAR_BIT,
- INT, UINT,
- 1, 1, 0, 1, 1, "unsigned int" } },
- { LONG, { sizeof (long) * CHAR_BIT, 4 * CHAR_BIT,
- LONG, ULONG,
- 1, 0, 0, 1, 1, "long" } },
- { ULONG, { sizeof (u_long) * CHAR_BIT, 4 * CHAR_BIT,
- LONG, ULONG,
- 1, 1, 0, 1, 1, "unsigned long" } },
- { QUAD, { sizeof (quad_t) * CHAR_BIT, 8 * CHAR_BIT,
- QUAD, UQUAD,
- 1, 0, 0, 1, 1, "long long" } },
- { UQUAD, { sizeof (u_quad_t) * CHAR_BIT, 8 * CHAR_BIT,
- QUAD, UQUAD,
- 1, 1, 0, 1, 1, "unsigned long long" } },
- { FLOAT, { sizeof (float) * CHAR_BIT, 4 * CHAR_BIT,
- FLOAT, FLOAT,
- 0, 0, 1, 1, 1, "float" } },
- { DOUBLE, { sizeof (double) * CHAR_BIT, 8 * CHAR_BIT,
- DOUBLE, DOUBLE,
- 0, 0, 1, 1, 1, "double" } },
- { LDOUBLE, { sizeof (ldbl_t) * CHAR_BIT, 10 * CHAR_BIT,
- LDOUBLE, LDOUBLE,
- 0, 0, 1, 1, 1, "long double" } },
- { VOID, { -1, -1,
- VOID, VOID,
- 0, 0, 0, 0, 0, "void" } },
- { STRUCT, { -1, -1,
- STRUCT, STRUCT,
- 0, 0, 0, 0, 0, "struct" } },
- { UNION, { -1, -1,
- UNION, UNION,
- 0, 0, 0, 0, 0, "union" } },
- { ENUM, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
- ENUM, ENUM,
- 1, 0, 0, 1, 1, "enum" } },
- { PTR, { sizeof (void *) * CHAR_BIT, 4 * CHAR_BIT,
- PTR, PTR,
- 0, 1, 0, 0, 1, "pointer" } },
- { ARRAY, { -1, -1,
- ARRAY, ARRAY,
- 0, 0, 0, 0, 0, "array" } },
- { FUNC, { -1, -1,
- FUNC, FUNC,
- 0, 0, 0, 0, 0, "function" } },
- };
-
- for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
- STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
- if (!pflag) {
- for (i = 0; i < NTSPEC; i++)
- ttab[i].tt_psz = ttab[i].tt_sz;
- }
-}
+static void chkund(hte_t *);
+static void chkdnu(hte_t *);
+static void chkdnud(hte_t *);
+static void chkmd(hte_t *);
+static void chkvtui(hte_t *, sym_t *, sym_t *);
+static void chkvtdi(hte_t *, sym_t *, sym_t *);
+static void chkfaui(hte_t *, sym_t *, sym_t *);
+static void chkau(hte_t *, int, sym_t *, sym_t *, pos_t *,
+ fcall_t *, fcall_t *, type_t *, type_t *);
+static void chkrvu(hte_t *, sym_t *);
+static void chkadecl(hte_t *, sym_t *, sym_t *);
+static void printflike(hte_t *,fcall_t *, int, const char *, type_t **);
+static void scanflike(hte_t *, fcall_t *, int, const char *, type_t **);
+static void badfmt(hte_t *, fcall_t *);
+static void inconarg(hte_t *, fcall_t *, int);
+static void tofewarg(hte_t *, fcall_t *);
+static void tomanyarg(hte_t *, fcall_t *);
+static int eqtype(type_t *, type_t *, int, int, int, int *);
+static int eqargs(type_t *, type_t *, int *);
+static int mnoarg(type_t *, int *);
/*
* If there is a symbol named "main", mark it as used.
*/
void
-mainused()
+mainused(void)
{
hte_t *hte;
@@ -174,8 +81,7 @@ mainused()
* Performs all tests for a single name
*/
void
-chkname(hte)
- hte_t *hte;
+chkname(hte_t *hte)
{
sym_t *sym, *def, *pdecl, *decl;
@@ -220,8 +126,7 @@ chkname(hte)
* Print a warning if the name has been used, but not defined.
*/
static void
-chkund(hte)
- hte_t *hte;
+chkund(hte_t *hte)
{
fcall_t *fcall;
usym_t *usym;
@@ -242,8 +147,7 @@ chkund(hte)
* Print a warning if the name has been defined, but never used.
*/
static void
-chkdnu(hte)
- hte_t *hte;
+chkdnu(hte_t *hte)
{
sym_t *sym;
@@ -260,33 +164,33 @@ chkdnu(hte)
}
/*
- * Print a warning if the name has been declared, but is not used
+ * Print a warning if the variable has been declared, but is not used
* or defined.
*/
static void
-chkdnud(hte)
- hte_t *hte;
+chkdnud(hte_t *hte)
{
sym_t *sym;
if (hte->h_syms == NULL || hte->h_used || hte->h_def)
return;
-
- if ((sym = hte->h_syms) != NULL) {
- if (sym->s_def != DECL)
- errx(1, "internal error: chkdnud() 1");
- /* %s declared( %s ), but never used or defined */
- msg(2, hte->h_name, mkpos(&sym->s_pos));
- }
+
+ sym = hte->h_syms;
+ if (TP(sym->s_type)->t_tspec == FUNC)
+ return;
+
+ if (sym->s_def != DECL)
+ errx(1, "internal error: chkdnud() 1");
+ /* %s declared( %s ), but never used or defined */
+ msg(2, hte->h_name, mkpos(&sym->s_pos));
}
/*
- * Print a warning if there is more then one definition for
+ * Print a warning if there is more than one definition for
* this name.
*/
static void
-chkmd(hte)
- hte_t *hte;
+chkmd(hte_t *hte)
{
sym_t *sym, *def1;
char *pos1;
@@ -323,9 +227,7 @@ chkmd(hte)
* call as it's done for function arguments.
*/
static void
-chkvtui(hte, def, decl)
- hte_t *hte;
- sym_t *def, *decl;
+chkvtui(hte_t *hte, sym_t *def, sym_t *decl)
{
fcall_t *call;
char *pos1;
@@ -386,9 +288,7 @@ chkvtui(hte, def, decl)
* types of return values are tested.
*/
static void
-chkvtdi(hte, def, decl)
- hte_t *hte;
- sym_t *def, *decl;
+chkvtdi(hte_t *hte, sym_t *def, sym_t *decl)
{
sym_t *sym;
type_t *tp1, *tp2;
@@ -427,12 +327,10 @@ chkvtdi(hte, def, decl)
* of the same function.
*/
static void
-chkfaui(hte, def, decl)
- hte_t *hte;
- sym_t *def, *decl;
+chkfaui(hte_t *hte, sym_t *def, sym_t *decl)
{
type_t *tp1, *tp2, **ap1, **ap2;
- pos_t *pos1p;
+ pos_t *pos1p = NULL;
fcall_t *calls, *call, *call1;
int n, as;
char *pos1;
@@ -442,7 +340,7 @@ chkfaui(hte, def, decl)
return;
/*
- * If we find a function definition, we use this for comparision,
+ * If we find a function definition, we use this for comparison,
* otherwise the first prototype we can find. If there is no
* definition or prototype declaration, the first function call
* is used.
@@ -537,13 +435,8 @@ chkfaui(hte, def, decl)
*
*/
static void
-chkau(hte, n, def, decl, pos1p, call1, call, arg1, arg2)
- hte_t *hte;
- int n;
- sym_t *def, *decl;
- pos_t *pos1p;
- fcall_t *call1, *call;
- type_t *arg1, *arg2;
+chkau(hte_t *hte, int n, sym_t *def, sym_t *decl, pos_t *pos1p,
+ fcall_t *call1, fcall_t *call, type_t *arg1, type_t *arg2)
{
/* LINTED (automatic hides external declaration: warn) */
int promote, asgn, warn;
@@ -577,7 +470,7 @@ chkau(hte, n, def, decl, pos1p, call1, call, arg1, arg2)
/*
* Other lint implementations print warnings as soon as the type
* of an argument does not match exactly the expected type. The
- * result are lots of warnings which are really not neccessary.
+ * result are lots of warnings which are really not necessary.
* We print a warning only if
* (0) at least one type is not an interger type and types differ
* (1) hflag is set and types differ
@@ -670,11 +563,16 @@ chkau(hte, n, def, decl, pos1p, call1, call, arg1, arg2)
}
}
- } else if (t1 == PTR && isityp(t2) && psize(t1) == psize(t2)) {
+ } else if (t1 == PTR && isityp(t2)) {
for (ai = call->f_args; ai != NULL; ai = ai->a_nxt) {
if (ai->a_num == n)
break;
}
+ /*
+ * Vendor implementations of lint (e.g. HP-UX, Digital UNIX)
+ * don't care about the size of the integer argument,
+ * only whether or not it is zero. We do the same.
+ */
if (ai != NULL && ai->a_zero)
return;
}
@@ -690,17 +588,12 @@ chkau(hte, n, def, decl, pos1p, call1, call, arg1, arg2)
* string fmt.
*/
static void
-printflike(hte, call, n, fmt, ap)
- hte_t *hte;
- fcall_t *call;
- int n;
- const char *fmt;
- type_t **ap;
+printflike(hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap)
{
const char *fp;
int fc;
int fwidth, prec, left, sign, space, alt, zero;
- tspec_t sz, t1, t2;
+ tspec_t sz, t1, t2 = NOTSPEC;
type_t *tp;
fp = fmt;
@@ -920,18 +813,13 @@ printflike(hte, call, n, fmt, ap)
* string fmt.
*/
static void
-scanflike(hte, call, n, fmt, ap)
- hte_t *hte;
- fcall_t *call;
- int n;
- const char *fmt;
- type_t **ap;
+scanflike(hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap)
{
const char *fp;
int fc;
int noasgn, fwidth;
- tspec_t sz, t1, t2;
- type_t *tp;
+ tspec_t sz, t1 = NOTSPEC, t2 = NOTSPEC;
+ type_t *tp = NULL;
fp = fmt;
fc = *fp++;
@@ -955,7 +843,7 @@ scanflike(hte, call, n, fmt, ap)
noasgn = 1;
fc = *fp++;
}
-
+
if (isdigit(fc)) {
fwidth = 1;
do { fc = *fp++; } while (isdigit(fc));
@@ -1116,38 +1004,33 @@ scanflike(hte, call, n, fmt, ap)
}
static void
-badfmt(hte, call)
- hte_t *hte;
- fcall_t *call;
+badfmt(hte_t *hte, fcall_t *call)
{
+
/* %s: malformed format string\t%s */
msg(13, hte->h_name, mkpos(&call->f_pos));
}
static void
-inconarg(hte, call, n)
- hte_t *hte;
- fcall_t *call;
- int n;
+inconarg(hte_t *hte, fcall_t *call, int n)
{
+
/* %s, arg %d inconsistent with format\t%s(%d) */
msg(14, hte->h_name, n, mkpos(&call->f_pos));
}
static void
-tofewarg(hte, call)
- hte_t *hte;
- fcall_t *call;
+tofewarg(hte_t *hte, fcall_t *call)
{
+
/* %s: too few args for format \t%s */
msg(15, hte->h_name, mkpos(&call->f_pos));
}
static void
-tomanyarg(hte, call)
- hte_t *hte;
- fcall_t *call;
+tomanyarg(hte_t *hte, fcall_t *call)
{
+
/* %s: too many args for format \t%s */
msg(16, hte->h_name, mkpos(&call->f_pos));
}
@@ -1158,9 +1041,7 @@ tomanyarg(hte, call)
* or return values which are always or sometimes ignored.
*/
static void
-chkrvu(hte, def)
- hte_t *hte;
- sym_t *def;
+chkrvu(hte_t *hte, sym_t *def)
{
fcall_t *call;
int used, ignored;
@@ -1176,7 +1057,7 @@ chkrvu(hte, def)
/* function has return value */
used = ignored = 0;
for (call = hte->h_calls; call != NULL; call = call->f_nxt) {
- used |= call->f_rused;
+ used |= call->f_rused || call->f_rdisc;
ignored |= !call->f_rused && !call->f_rdisc;
}
/*
@@ -1208,9 +1089,7 @@ chkrvu(hte, def)
* Print warnings for inconsistent argument declarations.
*/
static void
-chkadecl(hte, def, decl)
- hte_t *hte;
- sym_t *def, *decl;
+chkadecl(hte_t *hte, sym_t *def, sym_t *decl)
{
/* LINTED (automatic hides external declaration: warn) */
int osdef, eq, warn, n;
@@ -1280,8 +1159,8 @@ chkadecl(hte, def, decl)
*
* ignqual if set, ignore qualifiers of outhermost type; used for
* function arguments
- * promote if set, promote left type before comparision; used for
- * comparisions of arguments with parameters of old style
+ * promote if set, promote left type before comparison; used for
+ * comparisons of arguments with parameters of old style
* definitions
* asgn left indirected type must have at least the same qualifiers
* like right indirected type (for assignments and function
@@ -1290,9 +1169,7 @@ chkadecl(hte, def, decl)
* an incompatible prototype declaration
*/
static int
-eqtype(tp1, tp2, ignqual, promot, asgn, warn)
- type_t *tp1, *tp2;
- int ignqual, promot, asgn, *warn;
+eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int asgn, int *warn)
{
tspec_t t, to;
int indir;
@@ -1322,7 +1199,7 @@ eqtype(tp1, tp2, ignqual, promot, asgn, warn)
if (indir == 1 && (t == VOID || tp2->t_tspec == VOID))
return (1);
}
-
+
if (t != tp2->t_tspec) {
/*
* Give pointer to types which differ only in
@@ -1339,6 +1216,13 @@ eqtype(tp1, tp2, ignqual, promot, asgn, warn)
return (tp1->t_tag == tp2->t_tag);
} else if (tp1->t_istynam && tp2->t_istynam) {
return (tp1->t_tynam == tp2->t_tynam);
+ } else if (tp1->t_isuniqpos && tp2->t_isuniqpos) {
+ return (tp1->t_uniqpos.p_line ==
+ tp2->t_uniqpos.p_line &&
+ tp1->t_uniqpos.p_file ==
+ tp2->t_uniqpos.p_file &&
+ tp1->t_uniqpos.p_uniq ==
+ tp2->t_uniqpos.p_uniq);
} else {
return (0);
}
@@ -1366,6 +1250,13 @@ eqtype(tp1, tp2, ignqual, promot, asgn, warn)
return (tp1->t_tag == tp2->t_tag);
} else if (tp1->t_istynam && tp2->t_istynam) {
return (tp1->t_tynam == tp2->t_tynam);
+ } else if (tp1->t_isuniqpos && tp2->t_isuniqpos) {
+ return (tp1->t_uniqpos.p_line ==
+ tp2->t_uniqpos.p_line &&
+ tp1->t_uniqpos.p_file ==
+ tp2->t_uniqpos.p_file &&
+ tp1->t_uniqpos.p_uniq ==
+ tp2->t_uniqpos.p_uniq);
} else {
return (0);
}
@@ -1404,9 +1295,7 @@ eqtype(tp1, tp2, ignqual, promot, asgn, warn)
* Compares arguments of two prototypes
*/
static int
-eqargs(tp1, tp2, warn)
- type_t *tp1, *tp2;
- int *warn;
+eqargs(type_t *tp1, type_t *tp2, int *warn)
{
type_t **a1, **a2;
@@ -1440,9 +1329,7 @@ eqargs(tp1, tp2, warn)
* is applied on it
*/
static int
-mnoarg(tp, warn)
- type_t *tp;
- int *warn;
+mnoarg(type_t *tp, int *warn)
{
type_t **arg;
tspec_t t;
@@ -1459,4 +1346,3 @@ mnoarg(tp, warn)
}
return (1);
}
-
diff --git a/usr.bin/xlint/lint2/emit2.c b/usr.bin/xlint/lint2/emit2.c
index 82527b5..1b4510f 100644
--- a/usr.bin/xlint/lint2/emit2.c
+++ b/usr.bin/xlint/lint2/emit2.c
@@ -1,6 +1,7 @@
-/* $NetBSD: emit2.c,v 1.2 1995/07/03 21:24:44 cgd Exp $ */
+/* $NetBSD: emit2.c,v 1.8 2002/01/21 19:49:52 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -31,24 +32,23 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: emit2.c,v 1.2 1995/07/03 21:24:44 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: emit2.c,v 1.8 2002/01/21 19:49:52 tv Exp $");
#endif
-#include <err.h>
-
#include "lint2.h"
-static void outtype __P((type_t *));
-static void outdef __P((hte_t *, sym_t *));
-static void dumpname __P((hte_t *));
+static void outtype(type_t *);
+static void outdef(hte_t *, sym_t *);
+static void dumpname(hte_t *);
+static void outfiles(void);
/*
* Write type into the output buffer.
*/
static void
-outtype(tp)
- type_t *tp;
+outtype(type_t *tp)
{
int t, s, na;
tspec_t ts;
@@ -105,9 +105,15 @@ outtype(tp)
} else if (tp->t_istynam) {
outint(2);
outname(tp->t_tynam->h_name);
- } else {
- outint(0);
- }
+ } else if (tp->t_isuniqpos) {
+ outint(3);
+ outint(tp->t_uniqpos.p_line);
+ outchar('.');
+ outint(tp->t_uniqpos.p_file);
+ outchar('.');
+ outint(tp->t_uniqpos.p_uniq);
+ } else
+ errx(1, "internal error: outtype() 2");
} else if (ts == FUNC && tp->t_args != NULL) {
na = 0;
for (ap = tp->t_args; *ap != NULL; ap++)
@@ -128,10 +134,9 @@ outtype(tp)
* Write a definition.
*/
static void
-outdef(hte, sym)
- hte_t *hte;
- sym_t *sym;
+outdef(hte_t *hte, sym_t *sym)
{
+
/* reset output buffer */
outclr();
@@ -180,8 +185,7 @@ outdef(hte, sym)
* Write the first definition of a name into the lint library.
*/
static void
-dumpname(hte)
- hte_t *hte;
+dumpname(hte_t *hte)
{
sym_t *sym, *def;
@@ -191,7 +195,7 @@ dumpname(hte)
/*
* If there is a definition, write it. Otherwise write a tentative
- * definition. This is neccessary because more than one tentative
+ * definition. This is necessary because more than one tentative
* definition is allowed (except with sflag).
*/
def = NULL;
@@ -213,8 +217,7 @@ dumpname(hte)
* Write a new lint library.
*/
void
-outlib(name)
- const char *name;
+outlib(const char *name)
{
/* Open of output file and initialisation of the output buffer */
outopen(name);
@@ -228,9 +231,67 @@ outlib(name)
outchar('s');
outstrg(name);
+ /*
+ * print the names of all files references by unnamed
+ * struct/union/enum declarations.
+ */
+ outfiles();
+
/* write all definitions with external linkage */
forall(dumpname);
/* close the output */
outclose();
}
+
+/*
+ * Write out the name of a file referenced by a type.
+ */
+struct outflist {
+ short ofl_num;
+ struct outflist *ofl_next;
+};
+static struct outflist *outflist;
+
+int
+addoutfile(short num)
+{
+ struct outflist *ofl, **pofl;
+ int i;
+
+ ofl = outflist;
+ pofl = &outflist;
+ i = 1; /* library is 0 */
+
+ while (ofl != NULL) {
+ if (ofl->ofl_num == num)
+ break;
+
+ pofl = &ofl->ofl_next;
+ ofl = ofl->ofl_next;
+ i++;
+ }
+
+ if (ofl == NULL) {
+ ofl = *pofl = xmalloc(sizeof (struct outflist));
+ ofl->ofl_num = num;
+ ofl->ofl_next = NULL;
+ }
+ return (i);
+}
+
+static void
+outfiles(void)
+{
+ struct outflist *ofl;
+ int i;
+
+ for (ofl = outflist, i = 1; ofl != NULL; ofl = ofl->ofl_next, i++) {
+ /* reset output buffer */
+ outclr();
+
+ outint(i);
+ outchar('s');
+ outstrg(fnames[ofl->ofl_num]);
+ }
+}
diff --git a/usr.bin/xlint/lint2/externs2.h b/usr.bin/xlint/lint2/externs2.h
index 2e65e53..3b6f03a 100644
--- a/usr.bin/xlint/lint2/externs2.h
+++ b/usr.bin/xlint/lint2/externs2.h
@@ -1,6 +1,7 @@
-/* $NetBSD: externs2.h,v 1.2 1995/07/03 21:24:46 cgd Exp $ */
+/* $NetBSD: externs2.h,v 1.7 2001/05/28 12:40:38 lukem Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -38,7 +39,6 @@ extern int xflag;
extern int uflag;
extern int Cflag;
extern const char *libname;
-extern int pflag;
extern int sflag;
extern int tflag;
extern int Hflag;
@@ -49,9 +49,14 @@ extern int Fflag;
/*
* hash.c
*/
-extern void inithash __P((void));
-extern hte_t *hsearch __P((const char *, int));
-extern void forall __P((void (*)(hte_t *)));
+extern void _inithash(hte_t ***);
+extern hte_t *_hsearch(hte_t **, const char *, int);
+extern void _forall(hte_t **, void (*)(hte_t *));
+extern void _destroyhash(hte_t **);
+
+#define inithash() _inithash(NULL);
+#define hsearch(a, b) _hsearch(NULL, (a), (b))
+#define forall(a) _forall(NULL, (a))
/*
* read.c
@@ -59,29 +64,30 @@ extern void forall __P((void (*)(hte_t *)));
extern const char **fnames;
extern type_t **tlst;
-extern void readfile __P((const char *));
-extern void mkstatic __P((hte_t *));
+extern void readfile(const char *);
+extern void mkstatic(hte_t *);
/*
* mem2.c
*/
-extern void initmem __P((void));
-extern void *xalloc __P((size_t));
+extern void initmem(void);
+extern void *xalloc(size_t);
/*
* chk.c
*/
-extern void inittyp __P((void));
-extern void mainused __P((void));
-extern void chkname __P((hte_t *));
+extern void inittyp(void);
+extern void mainused(void);
+extern void chkname(hte_t *);
/*
* msg.c
*/
-extern void msg __P((int, ...));
-extern const char *mkpos __P((pos_t *));
+extern void msg(int, ...);
+extern const char *mkpos(pos_t *);
/*
* emit2.c
*/
-extern void outlib __P((const char *));
+extern void outlib(const char *);
+extern int addoutfile(short);
diff --git a/usr.bin/xlint/lint2/hash.c b/usr.bin/xlint/lint2/hash.c
index 7901802..fac7358 100644
--- a/usr.bin/xlint/lint2/hash.c
+++ b/usr.bin/xlint/lint2/hash.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.c,v 1.2 1995/07/03 21:24:47 cgd Exp $ */
+/* $NetBSD: hash.c,v 1.7 2002/01/21 19:49:52 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,36 +31,45 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: hash.c,v 1.2 1995/07/03 21:24:47 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: hash.c,v 1.7 2002/01/21 19:49:52 tv Exp $");
#endif
+/*
+ * XXX Really need a generalized hash table package
+ */
+
+#include <limits.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
-#include <limits.h>
#include "lint2.h"
/* pointer to hash table, initialized in inithash() */
static hte_t **htab;
-static int hash __P((const char *));
+static int hash(const char *);
/*
* Initialize hash table.
*/
void
-inithash()
+_inithash(hte_t ***tablep)
{
- htab = xcalloc(HSHSIZ2, sizeof (hte_t *));
+
+ if (tablep == NULL)
+ tablep = &htab;
+
+ *tablep = xcalloc(HSHSIZ2, sizeof (hte_t *));
}
/*
* Compute hash value from a string.
*/
static int
-hash(s)
- const char *s;
+hash(const char *s)
{
u_int v;
const u_char *us;
@@ -78,15 +87,16 @@ hash(s)
* given name exists and mknew is set, create a new one.
*/
hte_t *
-hsearch(s, mknew)
- const char *s;
- int mknew;
+_hsearch(hte_t **table, const char *s, int mknew)
{
int h;
hte_t *hte;
+ if (table == NULL)
+ table = htab;
+
h = hash(s);
- for (hte = htab[h]; hte != NULL; hte = hte->h_link) {
+ for (hte = table[h]; hte != NULL; hte = hte->h_link) {
if (strcmp(hte->h_name, s) == 0)
break;
}
@@ -95,13 +105,20 @@ hsearch(s, mknew)
return (hte);
/* create a new hte */
- hte = xalloc(sizeof (hte_t));
+ hte = xmalloc(sizeof (hte_t));
hte->h_name = xstrdup(s);
+ hte->h_used = 0;
+ hte->h_def = 0;
+ hte->h_static = 0;
+ hte->h_syms = NULL;
hte->h_lsym = &hte->h_syms;
+ hte->h_calls = NULL;
hte->h_lcall = &hte->h_calls;
+ hte->h_usyms = NULL;
hte->h_lusym = &hte->h_usyms;
- hte->h_link = htab[h];
- htab[h] = hte;
+ hte->h_link = table[h];
+ hte->h_hte = NULL;
+ table[h] = hte;
return (hte);
}
@@ -110,14 +127,38 @@ hsearch(s, mknew)
* Call function f for each name in the hash table.
*/
void
-forall(f)
- void (*f) __P((hte_t *));
+_forall(hte_t **table, void (*f)(hte_t *))
{
int i;
hte_t *hte;
+ if (table == NULL)
+ table = htab;
+
for (i = 0; i < HSHSIZ2; i++) {
- for (hte = htab[i]; hte != NULL; hte = hte->h_link)
+ for (hte = table[i]; hte != NULL; hte = hte->h_link)
(*f)(hte);
}
}
+
+/*
+ * Free all contents of the hash table that this module allocated.
+ */
+void
+_destroyhash(hte_t **table)
+{
+ int i;
+ hte_t *hte, *nexthte;
+
+ if (table == NULL)
+ err(1, "_destroyhash called on main hash table");
+
+ for (i = 0; i < HSHSIZ2; i++) {
+ for (hte = table[i]; hte != NULL; hte = nexthte) {
+ free((void *)hte->h_name);
+ nexthte = hte->h_link;
+ free(hte);
+ }
+ }
+ free(table);
+}
diff --git a/usr.bin/xlint/lint2/lint2.h b/usr.bin/xlint/lint2/lint2.h
index 0ade110..75f9dc9 100644
--- a/usr.bin/xlint/lint2/lint2.h
+++ b/usr.bin/xlint/lint2/lint2.h
@@ -1,6 +1,7 @@
-/* $NetBSD: lint2.h,v 1.2 1995/07/03 21:24:49 cgd Exp $ */
+/* $NetBSD: lint2.h,v 1.5 2000/06/14 06:49:23 cgd Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -45,6 +46,7 @@ typedef struct type {
u_int t_proto : 1; /* this is a prototype */
u_int t_istag : 1; /* tag with _t_tag valid */
u_int t_istynam : 1; /* tag with _t_tynam valid */
+ u_int t_isuniqpos : 1; /* tag with _t_uniqpos valid */
union {
int _t_dim; /* if the type is an ARRAY than this
is the dimension of the array. */
@@ -52,6 +54,13 @@ typedef struct type {
t_isenum, STRUCT or UNION */
struct hte *_t_tynam; /* hash table entry of typename if
t_isenum, STRUCT or UNION */
+ struct {
+ int p_line;
+ short p_file;
+ int p_uniq;
+ } _t_uniqpos; /* unique position, for untagged
+ untyped STRUCTs, UNIONS, and ENUMs,
+ if t_isuniqpos */
struct type **_t_args; /* list of argument types if this
is a prototype */
} t_u;
@@ -59,10 +68,11 @@ typedef struct type {
type, type of return value) */
} type_t;
-#define t_dim t_u._t_dim
-#define t_tag t_u._t_tag
-#define t_tynam t_u._t_tynam
-#define t_args t_u._t_args
+#define t_dim t_u._t_dim
+#define t_tag t_u._t_tag
+#define t_tynam t_u._t_tynam
+#define t_uniqpos t_u._t_uniqpos
+#define t_args t_u._t_args
/*
* argument information
@@ -90,7 +100,7 @@ typedef struct {
u_short p_line; /* line number in p_src */
u_short p_isrc; /* index of (included) file */
u_short p_iline; /* line number in p_iline */
-} pos_t;
+} pos_t;
/*
* Used for definitions and declarations
@@ -107,7 +117,7 @@ typedef struct sym {
u_int s_def : 3; /* DECL, TDEF or DEF */
#else
def_t s_def;
-#endif
+#endif
u_int s_rval : 1; /* function has return value */
u_int s_osdef : 1; /* old style function definition */
u_int s_static : 1; /* symbol is static */
@@ -169,6 +179,7 @@ typedef struct hte {
usym_t *h_usyms; /* usage info */
usym_t **h_lusym; /* points to u_nxt of last usage info */
struct hte *h_link; /* next hte with same hash function */
+ struct hte *h_hte; /* pointer to other htes (for renames */
} hte_t;
/* maps type indices into pointers to type structs */
diff --git a/usr.bin/xlint/lint2/main2.c b/usr.bin/xlint/lint2/main2.c
index 171344a..71e8c10 100644
--- a/usr.bin/xlint/lint2/main2.c
+++ b/usr.bin/xlint/lint2/main2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main2.c,v 1.2 1995/07/03 21:24:53 cgd Exp $ */
+/* $NetBSD: main2.c,v 1.5 2001/11/21 19:14:26 wiz Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,8 +31,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: main2.c,v 1.2 1995/07/03 21:24:53 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: main2.c,v 1.5 2001/11/21 19:14:26 wiz Exp $");
#endif
#include <stdio.h>
@@ -58,7 +59,7 @@ const char *libname;
int pflag;
/*
- * warnings for (tentative) definitions of the same name in more then
+ * warnings for (tentative) definitions of the same name in more than
* one translation unit
*/
int sflag;
@@ -83,13 +84,12 @@ int Fflag;
*/
const char **libs;
-static void usage __P((void));
+static void usage(void);
+int main(int, char *[]);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int c, i;
size_t len;
@@ -133,8 +133,9 @@ main(argc, argv)
Fflag = 1;
break;
case 'l':
- for (i = 0; libs[i] != NULL; i++) ;
- libs = xrealloc(libs, (i + 2) * sizeof (char *));
+ for (i = 0; libs[i] != NULL; i++)
+ continue;
+ libs = xrealloc(libs, (i + 2) * sizeof (char *));
libs[i] = xstrdup(optarg);
libs[i + 1] = NULL;
break;
@@ -142,7 +143,7 @@ main(argc, argv)
usage();
}
}
-
+
argc -= optind;
argv += optind;
@@ -181,10 +182,9 @@ main(argc, argv)
}
static void
-usage()
+usage(void)
{
(void)fprintf(stderr,
"usage: lint2 -hpstxuHF -Clib -l lib ... src1 ...\n");
exit(1);
}
-
diff --git a/usr.bin/xlint/lint2/mem2.c b/usr.bin/xlint/lint2/mem2.c
index 06d7491..87d5a1b 100644
--- a/usr.bin/xlint/lint2/mem2.c
+++ b/usr.bin/xlint/lint2/mem2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mem2.c,v 1.3 1995/10/02 17:27:11 jpo Exp $ */
+/* $NetBSD: mem2.c,v 1.6 2002/01/21 19:49:52 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,8 +31,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: mem2.c,v 1.3 1995/10/02 17:27:11 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: mem2.c,v 1.6 2002/01/21 19:49:52 tv Exp $");
#endif
#include <sys/param.h>
@@ -40,7 +41,6 @@ static char rcsid[] = "$NetBSD: mem2.c,v 1.3 1995/10/02 17:27:11 jpo Exp $";
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
-#include <err.h>
#include "lint2.h"
@@ -54,7 +54,7 @@ static size_t nxtfree;
static void *mbuf;
void
-initmem()
+initmem(void)
{
int pgsz;
@@ -70,13 +70,13 @@ initmem()
* need never to be freed.
*/
void *
-xalloc(sz)
- size_t sz;
+xalloc(size_t sz)
{
void *ptr;
int prot, flags;
- sz = ALIGN(sz);
+ /* Align to at least 8 bytes. */
+ sz = (sz + 7) & ~7L;
if (nxtfree + sz > mblklen) {
/* use mmap() instead of malloc() to avoid malloc overhead. */
prot = PROT_READ | PROT_WRITE;
@@ -84,8 +84,6 @@ xalloc(sz)
mbuf = mmap(NULL, mblklen, prot, flags, -1, (off_t)0);
if (mbuf == (void *)-1)
err(1, "can't map memory");
- if (ALIGN((u_long)mbuf) != (u_long)mbuf)
- errx(1, "mapped address is not aligned");
(void)memset(mbuf, 0, mblklen);
nxtfree = 0;
}
diff --git a/usr.bin/xlint/lint2/msg.c b/usr.bin/xlint/lint2/msg.c
index c55ba96..b4a6a31 100644
--- a/usr.bin/xlint/lint2/msg.c
+++ b/usr.bin/xlint/lint2/msg.c
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.c,v 1.2 1995/07/03 21:24:56 cgd Exp $ */
+/* $NetBSD: msg.c,v 1.6 2002/01/21 19:49:52 tv Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -31,22 +31,17 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: msg.c,v 1.2 1995/07/03 21:24:56 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: msg.c,v 1.6 2002/01/21 19:49:52 tv Exp $");
#endif
-#include <string.h>
-
#include <stdio.h>
-#ifdef __STDC__
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
+#include <string.h>
#include "lint2.h"
-
static const char *msgs[] = {
"%s used( %s ), but not defined", /* 0 */
"%s defined( %s ), but never used", /* 1 */
@@ -66,29 +61,17 @@ static const char *msgs[] = {
"%s: too few args for format \t%s", /* 15 */
"%s: too many args for format \t%s", /* 16 */
"%s function value must be declared before use \t%s :: %s",/* 17 */
+ "%s renamed multiple times \t%s :: %s", /* 18 */
};
-static const char *basename __P((const char *));
+static const char *lbasename(const char *);
-#ifdef __STDC__
void
msg(int n, ...)
{
-#else
-void
-msg(va_alist)
- va_dcl
- int n;
-{
-#endif
va_list ap;
-#ifdef __STDC__
va_start(ap, n);
-#else
- va_start(ap);
- n = va_arg(ap, int);
-#endif
(void)vprintf(msgs[n], ap);
(void)printf("\n");
@@ -100,8 +83,7 @@ msg(va_alist)
* Return a pointer to the last component of a path.
*/
static const char *
-basename(path)
- const char *path;
+lbasename(const char *path)
{
const char *cp, *cp1, *cp2;
@@ -122,8 +104,7 @@ basename(path)
* Create a string which describes a position in a source file.
*/
const char *
-mkpos(posp)
- pos_t *posp;
+mkpos(pos_t *posp)
{
size_t len;
const char *fn;
@@ -140,7 +121,7 @@ mkpos(posp)
}
qm = !Hflag && posp->p_src != posp->p_isrc;
- len = strlen(fn = basename(fnames[src]));
+ len = strlen(fn = lbasename(fnames[src]));
len += 3 * sizeof (u_short) + 4;
if (len > blen)
@@ -154,4 +135,3 @@ mkpos(posp)
return (buf);
}
-
diff --git a/usr.bin/xlint/lint2/read.c b/usr.bin/xlint/lint2/read.c
index daffe1e..d3e8f9e 100644
--- a/usr.bin/xlint/lint2/read.c
+++ b/usr.bin/xlint/lint2/read.c
@@ -1,6 +1,7 @@
-/* $NetBSD: read.c,v 1.2 1995/07/03 21:24:59 cgd Exp $ */
+/* $NetBSD: read.c,v 1.12 2002/01/21 19:49:52 tv Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -31,16 +32,16 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: read.c,v 1.2 1995/07/03 21:24:59 cgd Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: read.c,v 1.12 2002/01/21 19:49:52 tv Exp $");
#endif
+#include <ctype.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <err.h>
#include "lint2.h"
@@ -78,33 +79,34 @@ static thtab_t **thtab; /* hash table */
type_t **tlst; /* array for indexed access */
static size_t tlstlen; /* length of tlst */
+static hte_t **renametab;
+
/* index of current C source file (as spezified at the command line) */
static int csrcfile;
-static void inperr __P((void));
-static void setsrc __P((const char *));
-static void setfnid __P((int, const char *));
-static void funccall __P((pos_t *, const char *));
-static void decldef __P((pos_t *, const char *));
-static void usedsym __P((pos_t *, const char *));
-static u_short inptype __P((const char *, const char **));
-static int gettlen __P((const char *, const char **));
-static u_short findtype __P((const char *, size_t, int));
-static u_short storetyp __P((type_t *, const char *, size_t, int));
-static int thash __P((const char *, size_t));
-static char *inpqstrg __P((const char *, const char **));
-static const char *inpname __P((const char *, const char **));
-static int getfnidx __P((const char *));
+static void inperr(void);
+static void setsrc(const char *);
+static void setfnid(int, const char *);
+static void funccall(pos_t *, const char *);
+static void decldef(pos_t *, const char *);
+static void usedsym(pos_t *, const char *);
+static u_short inptype(const char *, const char **);
+static int gettlen(const char *, const char **);
+static u_short findtype(const char *, size_t, int);
+static u_short storetyp(type_t *, const char *, size_t, int);
+static int thash(const char *, size_t);
+static char *inpqstrg(const char *, const char **);
+static const char *inpname(const char *, const char **);
+static int getfnidx(const char *);
void
-readfile(name)
- const char *name;
+readfile(const char *name)
{
FILE *inp;
size_t len;
const char *cp;
- char *line, *eptr, rt;
+ char *line, *eptr, rt = '\0';
int cline, isrc, iline;
pos_t pos;
@@ -117,6 +119,8 @@ readfile(name)
if (thtab == NULL)
thtab = xcalloc(THSHSIZ2, sizeof (thtab_t));
+ _inithash(&renametab);
+
srcfile = getfnidx(name);
if ((inp = fopen(name, "r")) == NULL)
@@ -193,6 +197,8 @@ readfile(name)
}
+ _destroyhash(renametab);
+
if (ferror(inp))
err(1, "read error on %s", name);
@@ -201,8 +207,9 @@ readfile(name)
static void
-inperr()
+inperr(void)
{
+
errx(1, "input file error: %s", fnames[srcfile]);
}
@@ -211,23 +218,22 @@ inperr()
* currently read.
*/
static void
-setsrc(cp)
- const char *cp;
+setsrc(const char *cp)
{
+
csrcfile = getfnidx(cp);
}
/*
* setfnid() gets as input an index as used in an input file and the
- * associated file name. If neccessary, it creates a new lint2 file
+ * associated file name. If necessary, it creates a new lint2 file
* name index for this file name and creates the mapping of the index
* as used in the input file to the index used in lint2.
*/
static void
-setfnid(fid, cp)
- int fid;
- const char *cp;
+setfnid(int fid, const char *cp)
{
+
if (fid == -1)
inperr();
@@ -249,15 +255,14 @@ setfnid(fid, cp)
* Process a function call record (c-record).
*/
static void
-funccall(posp, cp)
- pos_t *posp;
- const char *cp;
+funccall(pos_t *posp, const char *cp)
{
arginf_t *ai, **lai;
char c, *eptr;
int rused, rdisc;
hte_t *hte;
fcall_t *fcall;
+ const char *name;
fcall = xalloc(sizeof (fcall_t));
STRUCT_ASSIGN(fcall->f_pos, *posp);
@@ -311,7 +316,14 @@ funccall(posp, cp)
fcall->f_rdisc = rdisc;
/* read name of function */
- hte = hsearch(inpname(cp, &cp), 1);
+ name = inpname(cp, &cp);
+
+ /* first look it up in the renaming table, then in the normal table */
+ hte = _hsearch(renametab, name, 0);
+ if (hte != NULL)
+ hte = hte->h_hte;
+ else
+ hte = hsearch(name, 1);
hte->h_used = 1;
fcall->f_type = inptype(cp, &cp);
@@ -327,14 +339,13 @@ funccall(posp, cp)
* Process a declaration or definition (d-record).
*/
static void
-decldef(posp, cp)
- pos_t *posp;
- const char *cp;
+decldef(pos_t *posp, const char *cp)
{
sym_t *symp, sym;
- char c, *ep;
- int used;
- hte_t *hte;
+ char c, *ep, *pos1;
+ int used, renamed;
+ hte_t *hte, *renamehte = NULL;
+ const char *name, *rename;
(void)memset(&sym, 0, sizeof (sym));
STRUCT_ASSIGN(sym.s_pos, *posp);
@@ -412,8 +423,35 @@ decldef(posp, cp)
}
}
- /* read symbol name */
- hte = hsearch(inpname(cp, &cp), 1);
+ /* read symbol name, doing renaming if necessary */
+ name = inpname(cp, &cp);
+ renamed = 0;
+ if (*cp == 'r') {
+ cp++;
+ name = xstrdup(name);
+ rename = inpname(cp, &cp);
+
+ /* enter it and see if it's already been renamed */
+ renamehte = _hsearch(renametab, name, 1);
+ if (renamehte->h_hte == NULL) {
+ hte = hsearch(rename, 1);
+ renamehte->h_hte = hte;
+ renamed = 1;
+ } else if (strcmp((hte = renamehte->h_hte)->h_name, rename)) {
+ pos1 = xstrdup(mkpos(&renamehte->h_syms->s_pos));
+ /* %s renamed multiple times\t%s :: %s */
+ msg(18, name, pos1, mkpos(&sym.s_pos));
+ free(pos1);
+ }
+ free((char *)name);
+ } else {
+ /* it might be a previously-done rename */
+ hte = _hsearch(renametab, name, 0);
+ if (hte != NULL)
+ hte = hte->h_hte;
+ else
+ hte = hsearch(name, 1);
+ }
hte->h_used |= used;
if (sym.s_def == DEF || sym.s_def == TDEF)
hte->h_def = 1;
@@ -449,6 +487,10 @@ decldef(posp, cp)
}
*hte->h_lsym = symp;
hte->h_lsym = &symp->s_nxt;
+
+ /* XXX hack so we can remember where a symbol was renamed */
+ if (renamed)
+ renamehte->h_syms = symp;
}
if (*cp != '\0')
@@ -459,12 +501,11 @@ decldef(posp, cp)
* Read an u-record (emited by lint1 if a symbol was used).
*/
static void
-usedsym(posp, cp)
- pos_t *posp;
- const char *cp;
+usedsym(pos_t *posp, const char *cp)
{
usym_t *usym;
hte_t *hte;
+ const char *name;
usym = xalloc(sizeof (usym_t));
STRUCT_ASSIGN(usym->u_pos, *posp);
@@ -473,7 +514,12 @@ usedsym(posp, cp)
if (*cp++ != 'x')
inperr();
- hte = hsearch(inpname(cp, &cp), 1);
+ name = inpname(cp, &cp);
+ hte = _hsearch(renametab, name, 0);
+ if (hte != NULL)
+ hte = hte->h_hte;
+ else
+ hte = hsearch(name, 1);
hte->h_used = 1;
*hte->h_lusym = usym;
@@ -484,13 +530,12 @@ usedsym(posp, cp)
* Read a type and return the index of this type.
*/
static u_short
-inptype(cp, epp)
- const char *cp, **epp;
+inptype(const char *cp, const char **epp)
{
char c, s, *eptr;
const char *ep;
type_t *tp;
- int narg, i, osdef;
+ int narg, i, osdef = 0;
size_t tlen;
u_short tidx;
int h;
@@ -600,8 +645,6 @@ inptype(cp, epp)
case STRUCT:
case UNION:
switch (*cp++) {
- case '0':
- break;
case '1':
tp->t_istag = 1;
tp->t_tag = hsearch(inpname(cp, &cp), 1);
@@ -610,9 +653,42 @@ inptype(cp, epp)
tp->t_istynam = 1;
tp->t_tynam = hsearch(inpname(cp, &cp), 1);
break;
+ case '3':
+ tp->t_isuniqpos = 1;
+ tp->t_uniqpos.p_line = strtol(cp, &eptr, 10);
+ cp = eptr;
+ cp++;
+ /* xlate to 'global' file name. */
+ tp->t_uniqpos.p_file =
+ addoutfile(inpfns[strtol(cp, &eptr, 10)]);
+ cp = eptr;
+ cp++;
+ tp->t_uniqpos.p_uniq = strtol(cp, &eptr, 10);
+ cp = eptr;
+ break;
}
break;
- /* LINTED (enumeration value(s) not handled in switch) */
+ case LONG:
+ case VOID:
+ case LDOUBLE:
+ case DOUBLE:
+ case FLOAT:
+ case UQUAD:
+ case QUAD:
+ case ULONG:
+ case UINT:
+ case INT:
+ case USHORT:
+ case SHORT:
+ case UCHAR:
+ case SCHAR:
+ case CHAR:
+ case UNSIGN:
+ case SIGNED:
+ case NOTSPEC:
+ break;
+ case NTSPEC:
+ abort();
}
*epp = cp;
@@ -623,8 +699,7 @@ inptype(cp, epp)
* Get the length of a type string.
*/
static int
-gettlen(cp, epp)
- const char *cp, **epp;
+gettlen(const char *cp, const char **epp)
{
const char *cp1;
char c, s, *eptr;
@@ -769,19 +844,56 @@ gettlen(cp, epp)
case STRUCT:
case UNION:
switch (*cp++) {
- case '0':
- break;
case '1':
(void)inpname(cp, &cp);
break;
case '2':
(void)inpname(cp, &cp);
break;
+ case '3':
+ /* unique position: line.file.uniquifier */
+ (void)strtol(cp, &eptr, 10);
+ if (cp == eptr)
+ inperr();
+ cp = eptr;
+ if (*cp++ != '.')
+ inperr();
+ (void)strtol(cp, &eptr, 10);
+ if (cp == eptr)
+ inperr();
+ cp = eptr;
+ if (*cp++ != '.')
+ inperr();
+ (void)strtol(cp, &eptr, 10);
+ if (cp == eptr)
+ inperr();
+ cp = eptr;
+ break;
default:
inperr();
}
break;
- /* LINTED (enumeration value(s) not handled in switch) */
+ case FLOAT:
+ case USHORT:
+ case SHORT:
+ case UCHAR:
+ case SCHAR:
+ case CHAR:
+ case UNSIGN:
+ case SIGNED:
+ case NOTSPEC:
+ case INT:
+ case UINT:
+ case DOUBLE:
+ case LDOUBLE:
+ case VOID:
+ case ULONG:
+ case QUAD:
+ case UQUAD:
+ case LONG:
+ break;
+ case NTSPEC:
+ abort();
}
*epp = cp;
@@ -792,10 +904,7 @@ gettlen(cp, epp)
* Search a type by it's type string.
*/
static u_short
-findtype(cp, len, h)
- const char *cp;
- size_t len;
- int h;
+findtype(const char *cp, size_t len, int h)
{
thtab_t *thte;
@@ -814,14 +923,9 @@ findtype(cp, len, h)
* if we read the same type string from the input file.
*/
static u_short
-storetyp(tp, cp, len, h)
- type_t *tp;
- const char *cp;
- size_t len;
- int h;
+storetyp(type_t *tp, const char *cp, size_t len, int h)
{
- /* 0 ist reserved */
- static u_int tidx = 1;
+ static u_int tidx = 1; /* 0 is reserved */
thtab_t *thte;
char *name;
@@ -854,9 +958,7 @@ storetyp(tp, cp, len, h)
* Hash function for types
*/
static int
-thash(s, len)
- const char *s;
- size_t len;
+thash(const char *s, size_t len)
{
u_int v;
@@ -872,8 +974,7 @@ thash(s, len)
* Read a string enclosed by "". This string may contain quoted chars.
*/
static char *
-inpqstrg(src, epp)
- const char *src, **epp;
+inpqstrg(const char *src, const char **epp)
{
char *strg, *dst;
size_t slen;
@@ -899,11 +1000,7 @@ inpqstrg(src, epp)
c = '\t';
break;
case 'v':
-#ifdef __STDC__
c = '\v';
-#else
- c = '\013';
-#endif
break;
case 'b':
c = '\b';
@@ -915,11 +1012,7 @@ inpqstrg(src, epp)
c = '\f';
break;
case 'a':
-#ifdef __STDC__
c = '\a';
-#else
- c = '\007';
-#endif
break;
case '\\':
c = '\\';
@@ -964,8 +1057,7 @@ inpqstrg(src, epp)
* Read the name of a symbol in static memory.
*/
static const char *
-inpname(cp, epp)
- const char *cp, **epp;
+inpname(const char *cp, const char **epp)
{
static char *buf;
static size_t blen = 0;
@@ -980,7 +1072,7 @@ inpname(cp, epp)
buf = xrealloc(buf, blen = len + 1);
for (i = 0; i < len; i++) {
c = *cp++;
- if (!isalnum(c) && c != '_')
+ if (!isalnum((unsigned char)c) && c != '_')
inperr();
buf[i] = c;
}
@@ -995,8 +1087,7 @@ inpname(cp, epp)
* a new entry and return the index of the newly created entry.
*/
static int
-getfnidx(fn)
- const char *fn;
+getfnidx(const char *fn)
{
int i;
@@ -1022,8 +1113,7 @@ getfnidx(fn)
* Separate symbols with static and external linkage.
*/
void
-mkstatic(hte)
- hte_t *hte;
+mkstatic(hte_t *hte)
{
sym_t *sym1, **symp, *sym;
fcall_t **callp, *call;
@@ -1067,16 +1157,22 @@ mkstatic(hte)
* XXX this entry should be put at the beginning of the list to
* avoid to process the same symbol twice.
*/
- for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link) ;
- nhte->h_link = xalloc(sizeof (hte_t));
+ for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link)
+ continue;
+ nhte->h_link = xmalloc(sizeof (hte_t));
nhte = nhte->h_link;
nhte->h_name = hte->h_name;
- nhte->h_static = 1;
nhte->h_used = 1;
nhte->h_def = 1; /* error in lint1 */
+ nhte->h_static = 1;
+ nhte->h_syms = NULL;
nhte->h_lsym = &nhte->h_syms;
+ nhte->h_calls = NULL;
nhte->h_lcall = &nhte->h_calls;
+ nhte->h_usyms = NULL;
nhte->h_lusym = &nhte->h_usyms;
+ nhte->h_link = NULL;
+ nhte->h_hte = NULL;
/*
* move all symbols used in this translation unit into the new
diff --git a/usr.bin/xlint/llib/Makefile b/usr.bin/xlint/llib/Makefile
index 2e24c31..fe917d8 100644
--- a/usr.bin/xlint/llib/Makefile
+++ b/usr.bin/xlint/llib/Makefile
@@ -1,20 +1,22 @@
-# $NetBSD: Makefile,v 1.2 1995/07/03 21:25:05 cgd Exp $
+# $NetBSD: Makefile,v 1.7 2000/06/14 20:22:19 matt Exp $
+
+.include <bsd.own.mk>
LIBS= llib-lposix.ln llib-lstdc.ln
-all: ${LIBS}
+.if ${MKLINT} != "no"
+FILES= ${LIBS}
+FILESDIR= ${LINTLIBDIR}
-install:
- install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \
- ${LIBS} ${DESTDIR}${LINTLIBDIR}
+realall: ${LIBS}
+.endif
-clean cleanall:
- rm -f ${LIBS}
+CLEANFILES+= ${LIBS}
llib-lposix.ln: llib-lposix
- lint -Cposix ${.ALLSRC}
+ ${LINT} ${LINTFLAGS} -Cposix ${.ALLSRC}
llib-lstdc.ln: llib-lstdc
- lint -Cstdc ${.ALLSRC}
+ ${LINT} ${LINTFLAGS} -Cstdc ${.ALLSRC}
.include <bsd.prog.mk>
diff --git a/usr.bin/xlint/llib/llib-lposix b/usr.bin/xlint/llib/llib-lposix
index db1b3cf..f3a5351 100644
--- a/usr.bin/xlint/llib/llib-lposix
+++ b/usr.bin/xlint/llib/llib-lposix
@@ -1,4 +1,4 @@
-/* $NetBSD: llib-lposix,v 1.2 1995/07/03 21:25:09 cgd Exp $ */
+/* $NetBSD$ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
diff --git a/usr.bin/xlint/llib/llib-lstdc b/usr.bin/xlint/llib/llib-lstdc
index f2b33da..90f456b 100644
--- a/usr.bin/xlint/llib/llib-lstdc
+++ b/usr.bin/xlint/llib/llib-lstdc
@@ -1,4 +1,4 @@
-/* $NetBSD: llib-lstdc,v 1.3 1995/07/03 21:39:28 cgd Exp $ */
+/* $NetBSD: llib-lstdc,v 1.2 1995/07/03 21:25:11 cgd Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
diff --git a/usr.bin/xlint/xlint/Makefile b/usr.bin/xlint/xlint/Makefile
index 41c833c..c49e6c2 100644
--- a/usr.bin/xlint/xlint/Makefile
+++ b/usr.bin/xlint/xlint/Makefile
@@ -1,17 +1,14 @@
-# $NetBSD: Makefile,v 1.2 1995/07/03 21:25:14 cgd Exp $
+# $NetBSD: Makefile,v 1.11 2001/10/25 02:22:56 thorpej Exp $
-.PATH: ${.CURDIR}/../lint1
+.PATH: ${.CURDIR}/../lint1
-PROG= xlint
-SRCS= xlint.c mem.c
-MAN= lint.1
+PROG= xlint
+SRCS= xlint.c mem.c
+PROGNAME= lint
+MAN= lint.1
-CFLAGS+=-I${.CURDIR}/../lint1
+CPPFLAGS+= -I${.CURDIR}/../lint1
-realinstall:
- install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${PROG} ${DESTDIR}${BINDIR}/lint
-
-
-.include "${.CURDIR}/../../Makefile.inc"
+.ifndef HOSTPROG
.include <bsd.prog.mk>
+.endif
diff --git a/usr.bin/xlint/xlint/lint.1 b/usr.bin/xlint/xlint/lint.1
index 99d459c..6c127e2 100644
--- a/usr.bin/xlint/xlint/lint.1
+++ b/usr.bin/xlint/xlint/lint.1
@@ -1,5 +1,6 @@
-.\" $NetBSD: lint.1,v 1.3 1995/10/23 13:45:31 jpo Exp $
+.\" $NetBSD: lint.1,v 1.20 2001/12/08 19:27:56 wiz Exp $
.\"
+.\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
.\" Copyright (c) 1994, 1995 Jochen Pohl
.\" All Rights Reserved.
.\"
@@ -29,37 +30,81 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd August 28, 1994
+.Dd May 24, 2001
.Dt LINT 1
-.Os NetBSD
+.Os
.Sh NAME
.Nm lint
-.Nd a C program verifier.
+.Nd a C program verifier
.Sh SYNOPSIS
-.Nm lint
-.Op Fl abceghprvxzHFV
-.Op Fl s Ns | Ns Fl t
-.Op Fl i Ns | Ns Fl nu
-.Op Fl D Ns Ar name Ns Op =def
-.Op Fl U Ns Ar name
-.Op Fl I Ns Ar directory
-.Op Fl L Ns Ar directory
-.Op Fl l Ns Ar library
-.Op Fl o Ns Ar outputfile
+.Nm
+.Op Fl abceghprvwxzHFV
+.Bk -words
+.Op Fl s | Fl t
+.Ek
+.Bk -words
+.Op Fl i | Fl nu
+.Ek
+.Bk -words
+.Op Fl D Ar name Ns Op =def
+.Ek
+.Bk -words
+.Op Fl U Ar name
+.Ek
+.Bk -words
+.Op Fl I Ar directory
+.Ek
+.Bk -words
+.Op Fl d Ar directory
+.Ek
+.Bk -words
+.Op Fl L Ar directory
+.Ek
+.Bk -words
+.Op Fl l Ar library
+.Ek
+.Bk -words
+.Op Fl o Ar outputfile
+.Ek
+.Bk -words
+.Op Fl B Ar directory
+.Ek
+.Bk -words
+.Op Fl X Ar id Ns Op ,id ...
+.Ek
.Ar
.Nm lint
-.Op Fl abceghprvzHFV
-.Op Fl s Ns | Ns Fl t
-.Fl C Ns Ar library
-.Op Fl D Ns Ar name Ns Op =def
-.Op Fl I Ns Ar directory
-.Op Fl U Ns Ar name
+.Op Fl abceghprvwzHFV
+.Bk -words
+.Op Fl s | Fl t
+.Ek
+.Bk -words
+.Fl C Ar library
+.Ek
+.Bk -words
+.Op Fl D Ar name Ns Op =def
+.Ek
+.Bk -words
+.Op Fl U Ar name
+.Ek
+.Bk -words
+.Op Fl I Ar directory
+.Ek
+.Bk -words
+.Op Fl d Ar directory
+.Ek
+.Bk -words
+.Op Fl B Ar directory
+.Ek
+.Bk -words
+.Op Fl X Ar id Ns Op ,id ...
+.Ek
.Ar
.Sh DESCRIPTION
.Nm
attempts to detect features of the named C program files
that are likely to be bugs, to be non-portable, or to be
-wasteful. It also performs stricter type checking then does
+wasteful. It also performs stricter type checking than does
the C compiler.
.Nm
runs the C preprocessor as its first phase, with the
@@ -67,10 +112,10 @@ preprocessor symbol
.Sy lint
defined to allow certain questionable code to be altered
or skipped by
-.Nm lint .
+.Nm "" .
Therefore, this symbol should be thought of as a reserved
word for all code that is to be checked by
-.Nm lint .
+.Nm "" .
.Pp
Among the possible problems that are currently noted are
unreachable statements, loops not entered at the top,
@@ -90,7 +135,7 @@ are taken to be C source files. Filename arguments with
names ending with
.Pa \&.ln
are taken to be the result of an earlier invocation of
-.Nm lint ,
+.Nm "" ,
with either the
.Fl i ,
.Fl o
@@ -143,6 +188,22 @@ if a complaint stems not from a given source file, but from one of
its included files, the source filename will be printed followed by
a question mark.
.Pp
+The special input file name
+.Dq Pa -
+causes
+.Nm
+to take input from standard input (until end of file) and process
+it as if it were a
+.Pa \&.c
+file.
+If the
+.Fl i
+flag is given and
+.Dq Pa -
+is named as one of the input files, the
+.Fl o
+flag must also be specified to provide an output file name.
+.Pp
.Sy Options
.Bl -tag -width Fl
.It Fl a
@@ -174,21 +235,25 @@ Complain about unusual operations on
and combinations of
.Sy enum Ns -
and
-.Sy integer Ns -Types.
+.Sy integer Ns -Types .
.It Fl g
Don't print warnings for some extensions of
.Xr gcc 1
to the C language. Currently these are nonconstant initializers in
automatic aggregate initializations, arithmetic on pointer to void,
+trailing commas in enum declarations, C++ -style
+.Dq //
+comments,
zero sized structures, subscripting of non-lvalue arrays, prototypes
overriding old style function declarations and long long
-integer types. The
+integer types.
+The
.Fl g
flag also turns on the keywords
.Sy asm
and
.Sy inline
-(alternate keywords with leading underscores for both
+(alternative keywords with leading underscores for both
.Sy asm
and
.Sy inline
@@ -204,7 +269,7 @@ file for every
file on the command line. These
.Pa \&.ln
files are the product of
-.Nm lint Ns 's
+.Nm "" Ns 's
first pass only, and are not checked for compatibility
between functions.
.It Fl n
@@ -237,7 +302,7 @@ are defined without leading and trailing underscores. The keywords
.Sy volatile
and
.Sy signed
-are not available in traditional C mode (although the alternate
+are not available in traditional C mode (although the alternative
keywords with leading underscores still are).
.It Fl u
Do not complain about functions and external variables used
@@ -248,13 +313,16 @@ on a subset of files comprising part of a larger program).
.It Fl v
Suppress complaints about unused arguments in functions.
.It Fl x
-Report variables refferd to by
+Report variables referred to by
.Sy extern
declarations, but never used.
.It Fl z
Do not complain about structures that are never defined
(for example, using a structure pointer without knowing
its contents).
+.It Fl B Ns Ar path
+Path to use when looking for the lint1 and lint2 binaries. Defualts to
+.Pa /usr/libexec .
.It Fl C Ns Ar library
Create a
.Nm
@@ -284,6 +352,10 @@ is defined as 1.
Add
.Ar directory
to the list of directories in which to search for include files.
+.It Fl d Ns Ar directory
+Use
+.Ar directory
+instead of /usr/include as the default place to find include files.
.It Fl l Ns Ar library
Include the lint library
.Pa llib-l Ns Ar library Ns Pa \&.ln .
@@ -306,7 +378,7 @@ followed by a question mark.
Name the output file
.Ar outputfile .
The output file produced is the input that is given to
-.Nm lint Ns 's
+.Nm "" Ns 's
second pass. The
.Fl o
option simply saves this file in the named output file. If the
@@ -327,13 +399,19 @@ for the preprocessor.
.It Fl V
Print the command lines constructed by the controller program to
run the C preprocessor and
-.Nm lint Ns 's
+.Nm "" Ns 's
first and second pass.
+.It Fl w
+Treat warnings as errors.
+.It Fl X Ar id Ns Op ,id ...
+Suppress error messages identified by the list of ids. A list of messages
+and ids can be found in
+.Xr lint 7 .
.El
.Pp
.Sy Input Grammar
.Pp
-.Nm lint Ns 's
+.Nm "" Ns 's
first pass reads standard C source files.
.Nm
recognizes the following C comments as commands.
@@ -348,6 +426,9 @@ arguments for usage; a missing
is taken to be 0 (this option acts like the
.Fl v
option for the next function).
+.It Li /* BITFIELDTYPE */
+Suppress error messages about illegal bitfield types if the type
+is an integer type, and suppress non-portable bitfield type warnings.
.It Li /* CONSTCOND */ No or Xo
.Li /* CONSTANTCOND */ No or
.Li /* CONSTANTCONDITION */
@@ -376,14 +457,14 @@ Also shut off complaints about unused function arguments.
.Xc
Suppresses any intra-file warning except those dealing with
unused variables or functions. This directive should be placed
-on the line immediately preceding where the lint warning occured.
+on the line immediately preceding where the lint warning occurred.
.It Li /* LONGLONG */
Suppress complaints about use of long long integer types.
.It Li /* NOTREACHED */
At appropriate points, inhibit complaints about unreachable code.
(This comment is typically placed just after calls to functions
like
-.Xr exit 2 ).
+.Xr exit 3 ) .
.It Li /* PRINTFLIKE Ns Ar n Li */
makes
.Nm
@@ -442,7 +523,7 @@ file that corresponds to the
file, and prints all messages that are about just that
source file. After all the source files have been separetely
run through
-.Nm lint ,
+.Nm "" ,
it is invoked once more (without the
.Fl i
option), listing all the
@@ -458,7 +539,7 @@ to be used to
.Nm
only the source files that have been modified since the last
time the set of source files were
-.Nm lint Ns No ed .
+.Nm "" Ns No ed .
.Sh ENVIRONMENT
.Bl -tag -width Fl
.It Ev LIBDIR
@@ -471,6 +552,9 @@ will be used to search for the libraries.
.It Ev TMPDIR
usually the path for temporary files can be redefined by setting
this environment variable.
+.It Ev CC
+Location of the C compiler program. Defaults to
+.Pa /usr/bin/cc .
.El
.Sh FILES
.Bl -tag -width /usr/libdata/lint/llib-lc.ln -compact
@@ -480,6 +564,7 @@ programs
various prebuilt lint libraries
.It Pa /tmp/lint*
temporaries
+.El
.Sh SEE ALSO
.Xr cc 1 ,
.Xr cpp 1 ,
@@ -488,7 +573,7 @@ temporaries
Jochen Pohl
.Sh BUGS
The routines
-.Xr exit 2 ,
+.Xr exit 3 ,
.Xr longjmp 3
and other functions that do not return are not understood; this
causes various incorrect diagnostics.
diff --git a/usr.bin/xlint/xlint/pathnames.h b/usr.bin/xlint/xlint/pathnames.h
index d03845d..7e7a77b 100644
--- a/usr.bin/xlint/xlint/pathnames.h
+++ b/usr.bin/xlint/xlint/pathnames.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pathnames.h,v 1.2 1995/07/03 21:25:20 cgd Exp $ */
+/* $NetBSD: pathnames.h,v 1.3 1999/04/22 04:40:58 mrg Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -32,7 +32,12 @@
*/
/* directory where lint1 and lint2 reside */
+#ifndef PATH_LIBEXEC
#define PATH_LIBEXEC "/usr/libexec"
+#endif
+
+/* directory where cc(1) resides */
+#define PATH_USRBIN "/usr/bin"
/* default library search path */
#define PATH_LINTLIB "/usr/libdata/lint"
diff --git a/usr.bin/xlint/xlint/xlint.c b/usr.bin/xlint/xlint/xlint.c
index 3e57797..bacf9c8 100644
--- a/usr.bin/xlint/xlint/xlint.c
+++ b/usr.bin/xlint/xlint/xlint.c
@@ -1,6 +1,7 @@
-/* $NetBSD: xlint.c,v 1.3 1995/10/23 14:29:30 jpo Exp $ */
+/* $NetBSD: xlint.c,v 1.26 2002/01/22 01:14:03 thorpej Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
@@ -31,33 +32,38 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static char rcsid[] = "$NetBSD: xlint.c,v 1.3 1995/10/23 14:29:30 jpo Exp $";
+#include <sys/cdefs.h>
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: xlint.c,v 1.26 2002/01/22 01:14:03 thorpej Exp $");
#endif
#include <sys/param.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <signal.h>
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <err.h>
-#include <errno.h>
-#include <paths.h>
#include "lint.h"
#include "pathnames.h"
+int main(int, char *[]);
+
/* directory for temporary files */
static const char *tmpdir;
/* path name for cpp output */
static char *cppout;
+/* file descriptor for cpp output */
+static int cppoutfd = -1;
+
/* files created by 1st pass */
static char **p1out;
@@ -67,11 +73,11 @@ static char **p2in;
/* library which will be created by 2nd pass */
static char *p2out;
-/* flags always passed to cpp */
-static char **cppflags;
+/* flags always passed to cc(1) */
+static char **cflags;
-/* flags for cpp, controled by sflag/tflag */
-static char **lcppflgs;
+/* flags for cc(1), controled by sflag/tflag */
+static char **lcflags;
/* flags for lint1 */
static char **l1flags;
@@ -91,8 +97,10 @@ static char **libs;
/* search path for libraries */
static char **libsrchpath;
+static char *libexec_path;
+
/* flags */
-static int iflag, oflag, Cflag, sflag, tflag, Fflag;
+static int iflag, oflag, Cflag, sflag, tflag, Fflag, dflag, Bflag;
/* print the commands executed to run the stages of compilation */
static int Vflag;
@@ -109,80 +117,80 @@ static int first = 1;
*/
static const char *currfn;
-
-static void appstrg __P((char ***, char *));
-static void appcstrg __P((char ***, const char *));
-static void applst __P((char ***, char *const *));
-static void freelst __P((char ***));
-static char *concat2 __P((const char *, const char *));
-static char *concat3 __P((const char *, const char *, const char *));
-static void terminate __P((int));
-static const char *basename __P((const char *, int));
-static void appdef __P((char ***, const char *));
-static void usage __P((void));
-static void fname __P((const char *, int));
-static void runchild __P((const char *, char *const *, const char *));
-static void findlibs __P((char *const *));
-static int rdok __P((const char *));
-static void lint2 __P((void));
-static void cat __P((char *const *, const char *));
+#if !defined(TARGET_PREFIX)
+#define TARGET_PREFIX ""
+#endif
+static const char target_prefix[] = TARGET_PREFIX;
+
+static void appstrg(char ***, char *);
+static void appcstrg(char ***, const char *);
+static void applst(char ***, char *const *);
+static void freelst(char ***);
+static char *concat2(const char *, const char *);
+static char *concat3(const char *, const char *, const char *);
+static void terminate(int) __attribute__((__noreturn__));
+static const char *lbasename(const char *, int);
+static void appdef(char ***, const char *);
+static void usage(void);
+static void fname(const char *);
+static void runchild(const char *, char *const *, const char *, int);
+static void findlibs(char *const *);
+static int rdok(const char *);
+static void lint2(void);
+static void cat(char *const *, const char *);
/*
* Some functions to deal with lists of strings.
* Take care that we get no surprises in case of asyncron signals.
*/
static void
-appstrg(lstp, s)
- char ***lstp, *s;
+appstrg(char ***lstp, char *s)
{
char **lst, **olst;
int i;
olst = *lstp;
- for (i = 0; olst[i] != NULL; i++) ;
- lst = xmalloc((i + 2) * sizeof (char *));
- (void)memcpy(lst, olst, i * sizeof (char *));
+ for (i = 0; olst[i] != NULL; i++)
+ continue;
+ lst = xrealloc(olst, (i + 2) * sizeof (char *));
lst[i] = s;
lst[i + 1] = NULL;
*lstp = lst;
-}
+}
static void
-appcstrg(lstp, s)
- char ***lstp;
- const char *s;
+appcstrg(char ***lstp, const char *s)
{
+
appstrg(lstp, xstrdup(s));
}
static void
-applst(destp, src)
- char ***destp;
- char *const *src;
+applst(char ***destp, char *const *src)
{
int i, k;
char **dest, **odest;
odest = *destp;
- for (i = 0; odest[i] != NULL; i++) ;
- for (k = 0; src[k] != NULL; k++) ;
- dest = xmalloc((i + k + 1) * sizeof (char *));
- (void)memcpy(dest, odest, i * sizeof (char *));
+ for (i = 0; odest[i] != NULL; i++)
+ continue;
+ for (k = 0; src[k] != NULL; k++)
+ continue;
+ dest = xrealloc(odest, (i + k + 1) * sizeof (char *));
for (k = 0; src[k] != NULL; k++)
dest[i + k] = xstrdup(src[k]);
dest[i + k] = NULL;
*destp = dest;
- free(odest);
}
static void
-freelst(lstp)
- char ***lstp;
+freelst(char ***lstp)
{
char *s;
int i;
- for (i = 0; (*lstp)[i] != NULL; i++) ;
+ for (i = 0; (*lstp)[i] != NULL; i++)
+ continue;
while (i-- > 0) {
s = (*lstp)[i];
(*lstp)[i] = NULL;
@@ -191,8 +199,7 @@ freelst(lstp)
}
static char *
-concat2(s1, s2)
- const char *s1, *s2;
+concat2(const char *s1, const char *s2)
{
char *s;
@@ -204,8 +211,7 @@ concat2(s1, s2)
}
static char *
-concat3(s1, s2, s3)
- const char *s1, *s2, *s3;
+concat3(const char *s1, const char *s2, const char *s3)
{
char *s;
@@ -221,11 +227,12 @@ concat3(s1, s2, s3)
* Clean up after a signal.
*/
static void
-terminate(signo)
- int signo;
+terminate(int signo)
{
int i;
+ if (cppoutfd != -1)
+ (void)close(cppoutfd);
if (cppout != NULL)
(void)remove(cppout);
@@ -248,9 +255,7 @@ terminate(signo)
* Returns strg if the string does not contain delim.
*/
static const char *
-basename(strg, delim)
- const char *strg;
- int delim;
+lbasename(const char *strg, int delim)
{
const char *cp, *cp1, *cp2;
@@ -265,34 +270,40 @@ basename(strg, delim)
}
static void
-appdef(lstp, def)
- char ***lstp;
- const char *def;
+appdef(char ***lstp, const char *def)
{
+
appstrg(lstp, concat2("-D__", def));
appstrg(lstp, concat3("-D__", def, "__"));
}
static void
-usage()
+usage(void)
{
- (void)printf("lint [-abceghprvxzHF] [-s|-t] [-i|-nu] [-Dname[=def]] [-Uname]\n");
- (void)printf(" [-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile] file ...\n");
- (void)printf("\n");
- (void)printf("lint [-abceghprvzHF] [-s|-t] -Clibrary [-Dname[=def]]\n");
- (void)printf(" [-Idirectory] [-Uname] file ...\n");
+
+ (void)fprintf(stderr,
+ "Usage: %s [-abceghprvwxzHF] [-s|-t] [-i|-nu] [-Dname[=def]]"
+ " [-Uname] [-X <id>[,<id>]...\n", getprogname());
+ (void)fprintf(stderr,
+ "\t[-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile]"
+ " file...\n");
+ (void)fprintf(stderr,
+ " %s [-abceghprvwzHF] [-s|-t] -Clibrary [-Dname[=def]]\n"
+ " [-X <id>[,<id>]...\n", getprogname());
+ (void)fprintf(stderr, "\t[-Idirectory] [-Uname] [-Bpath] file"
+ " ...\n");
terminate(-1);
}
+
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int c;
char flgbuf[3], *tmp, *s;
size_t len;
- struct utsname un;
+
+ setprogname(argv[0]);
if ((tmp = getenv("TMPDIR")) == NULL || (len = strlen(tmp)) == 0) {
tmpdir = xstrdup(_PATH_TMP);
@@ -304,15 +315,16 @@ main(argc, argv)
cppout = xmalloc(strlen(tmpdir) + sizeof ("lint0.XXXXXX"));
(void)sprintf(cppout, "%slint0.XXXXXX", tmpdir);
- if (mktemp(cppout) == NULL) {
+ cppoutfd = mkstemp(cppout);
+ if (cppoutfd == -1) {
warn("can't make temp");
terminate(-1);
}
p1out = xcalloc(1, sizeof (char *));
p2in = xcalloc(1, sizeof (char *));
- cppflags = xcalloc(1, sizeof (char *));
- lcppflgs = xcalloc(1, sizeof (char *));
+ cflags = xcalloc(1, sizeof (char *));
+ lcflags = xcalloc(1, sizeof (char *));
l1flags = xcalloc(1, sizeof (char *));
l2flags = xcalloc(1, sizeof (char *));
l2libs = xcalloc(1, sizeof (char *));
@@ -320,30 +332,25 @@ main(argc, argv)
libs = xcalloc(1, sizeof (char *));
libsrchpath = xcalloc(1, sizeof (char *));
- appcstrg(&cppflags, "-lang-c");
- appcstrg(&cppflags, "-undef");
- appcstrg(&cppflags, "-$");
- appcstrg(&cppflags, "-C");
- appcstrg(&cppflags, "-Wcomment");
- appcstrg(&cppflags, "-D__NetBSD__");
- appcstrg(&cppflags, "-Dlint"); /* XXX don't def. with -s */
- appdef(&cppflags, "lint");
- appdef(&cppflags, "unix");
-
- appcstrg(&lcppflgs, "-Wtraditional");
-
- if (uname(&un) == -1)
- err(1, "uname");
- appdef(&cppflags, un.machine);
- appstrg(&lcppflgs, concat2("-D", un.machine));
-
-#ifdef MACHINE_ARCH
- if (strcmp(un.machine, MACHINE_ARCH) != 0) {
- appdef(&cppflags, MACHINE_ARCH);
- appstrg(&lcppflgs, concat2("-D", MACHINE_ARCH));
- }
+ appcstrg(&cflags, "-E");
+ appcstrg(&cflags, "-x");
+ appcstrg(&cflags, "c");
+#if 0
+ appcstrg(&cflags, "-D__attribute__(x)=");
+ appcstrg(&cflags, "-D__extension__(x)=/*NOSTRICT*/0");
+#else
+ appcstrg(&cflags, "-U__GNUC__");
#endif
-
+ appcstrg(&cflags, "-Wp,-$");
+ appcstrg(&cflags, "-Wp,-CC");
+ appcstrg(&cflags, "-Wcomment");
+ appcstrg(&cflags, "-D__LINT__");
+ appcstrg(&cflags, "-Dlint"); /* XXX don't def. with -s */
+
+ appdef(&cflags, "lint");
+
+ appcstrg(&lcflags, "-Wtraditional");
+
appcstrg(&deflibs, "c");
if (signal(SIGHUP, terminate) == SIG_IGN)
@@ -352,14 +359,7 @@ main(argc, argv)
(void)signal(SIGQUIT, terminate);
(void)signal(SIGTERM, terminate);
- while (argc > optind) {
-
- argc -= optind;
- argv += optind;
- optind = 0;
-
- c = getopt(argc, argv, "abceghil:no:prstuvxzC:D:FHI:L:U:V");
-
+ while ((c = getopt(argc, argv, "abcd:eghil:no:prstuvwxzB:C:D:FHI:L:U:VX:")) != -1) {
switch (c) {
case 'a':
@@ -369,6 +369,7 @@ main(argc, argv)
case 'g':
case 'r':
case 'v':
+ case 'w':
case 'z':
(void)sprintf(flgbuf, "-%c", c);
appcstrg(&l1flags, flgbuf);
@@ -384,6 +385,12 @@ main(argc, argv)
appcstrg(&l2flags, flgbuf);
break;
+ case 'X':
+ (void)sprintf(flgbuf, "-%c", c);
+ appcstrg(&l1flags, flgbuf);
+ appcstrg(&l1flags, optarg);
+ break;
+
case 'i':
if (Cflag)
usage();
@@ -406,27 +413,29 @@ main(argc, argv)
case 's':
if (tflag)
usage();
- freelst(&lcppflgs);
- appcstrg(&lcppflgs, "-trigraphs");
- appcstrg(&lcppflgs, "-Wtrigraphs");
- appcstrg(&lcppflgs, "-pedantic");
- appcstrg(&lcppflgs, "-D__STRICT_ANSI__");
+ freelst(&lcflags);
+ appcstrg(&lcflags, "-trigraphs");
+ appcstrg(&lcflags, "-Wtrigraphs");
+ appcstrg(&lcflags, "-pedantic");
+ appcstrg(&lcflags, "-D__STRICT_ANSI__");
appcstrg(&l1flags, "-s");
appcstrg(&l2flags, "-s");
sflag = 1;
break;
+#if !HAVE_CONFIG_H
case 't':
if (sflag)
usage();
- freelst(&lcppflgs);
- appcstrg(&lcppflgs, "-traditional");
- appstrg(&lcppflgs, concat2("-D", MACHINE));
- appstrg(&lcppflgs, concat2("-D", MACHINE_ARCH));
+ freelst(&lcflags);
+ appcstrg(&lcflags, "-traditional");
+ appstrg(&lcflags, concat2("-D", MACHINE));
+ appstrg(&lcflags, concat2("-D", MACHINE_ARCH));
appcstrg(&l1flags, "-t");
appcstrg(&l2flags, "-t");
tflag = 1;
break;
+#endif
case 'x':
appcstrg(&l2flags, "-x");
@@ -442,11 +451,20 @@ main(argc, argv)
freelst(&deflibs);
break;
+ case 'd':
+ if (dflag)
+ usage();
+ dflag = 1;
+ appcstrg(&cflags, "-nostdinc");
+ appcstrg(&cflags, "-idirafter");
+ appcstrg(&cflags, optarg);
+ break;
+
case 'D':
case 'I':
case 'U':
(void)sprintf(flgbuf, "-%c", c);
- appstrg(&cppflags, concat2(flgbuf, optarg));
+ appstrg(&cflags, concat2(flgbuf, optarg));
break;
case 'l':
@@ -468,21 +486,64 @@ main(argc, argv)
appcstrg(&l2flags, "-H");
break;
+ case 'B':
+ Bflag = 1;
+ libexec_path = xstrdup(optarg);
+ break;
+
case 'V':
Vflag = 1;
break;
- case '?':
+ default:
usage();
/* NOTREACHED */
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ /*
+ * To avoid modifying getopt(3)'s state engine midstream, we
+ * explicitly accept just a few options after the first source file.
+ *
+ * In particular, only -l<lib> and -L<libdir> (and these with a space
+ * after -l or -L) are allowed.
+ */
+ while (argc > 0) {
+ const char *arg = argv[0];
+
+ if (arg[0] == '-') {
+ char ***list;
+
+ /* option */
+ switch (arg[1]) {
+ case 'l':
+ list = &libs;
+ break;
+
+ case 'L':
+ list = &libsrchpath;
+ break;
- case -1:
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ if (arg[2])
+ appcstrg(list, arg + 2);
+ else if (argc > 1) {
+ argc--;
+ appcstrg(list, *++argv);
+ } else
+ usage();
+ } else {
/* filename */
- fname(argv[0], argc == 1);
+ fname(arg);
first = 0;
- optind = 1;
}
-
+ argc--;
+ argv++;
}
if (first)
@@ -517,16 +578,17 @@ main(argc, argv)
* and pass it through lint1 if it is a C source.
*/
static void
-fname(name, last)
- const char *name;
- int last;
+fname(const char *name)
{
const char *bn, *suff;
char **args, *ofn, *path;
size_t len;
+ int is_stdin;
+ int fd;
- bn = basename(name, '/');
- suff = basename(bn, '.');
+ is_stdin = (strcmp(name, "-") == 0);
+ bn = lbasename(name, '/');
+ suff = lbasename(bn, '.');
if (strcmp(suff, "ln") == 0) {
/* only for lint2 */
@@ -535,14 +597,15 @@ fname(name, last)
return;
}
- if (strcmp(suff, "c") != 0 &&
+ if (!is_stdin && strcmp(suff, "c") != 0 &&
(strncmp(bn, "llib-l", 6) != 0 || bn != suff)) {
warnx("unknown file type: %s\n", name);
return;
}
- if (!iflag || !first || !last)
- (void)printf("%s:\n", Fflag ? name : bn);
+ if (!iflag || !first)
+ (void)printf("%s:\n",
+ is_stdin ? "{standard input}" : Fflag ? name : bn);
/* build the name of the output file of lint1 */
if (oflag) {
@@ -550,6 +613,10 @@ fname(name, last)
outputfn = NULL;
oflag = 0;
} else if (iflag) {
+ if (is_stdin) {
+ warnx("-i not supported without -o for standard input");
+ return;
+ }
ofn = xmalloc(strlen(bn) + (bn == suff ? 4 : 2));
len = bn == suff ? strlen(bn) : (suff - 1) - bn;
(void)sprintf(ofn, "%.*s", (int)len, bn);
@@ -557,42 +624,68 @@ fname(name, last)
} else {
ofn = xmalloc(strlen(tmpdir) + sizeof ("lint1.XXXXXX"));
(void)sprintf(ofn, "%slint1.XXXXXX", tmpdir);
- if (mktemp(ofn) == NULL) {
+ fd = mkstemp(ofn);
+ if (fd == -1) {
warn("can't make temp");
terminate(-1);
}
+ close(fd);
}
if (!iflag)
appcstrg(&p1out, ofn);
args = xcalloc(1, sizeof (char *));
- /* run cpp */
+ /* run cc */
- path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/cpp"));
- (void)sprintf(path, "%s/cpp", PATH_LIBEXEC);
+ if (getenv("CC") == NULL) {
+ path = xmalloc(strlen(PATH_USRBIN) + sizeof ("/cc"));
+ (void)sprintf(path, "%s/cc", PATH_USRBIN);
+ } else {
+ path = strdup(getenv("CC"));
+ }
appcstrg(&args, path);
- applst(&args, cppflags);
- applst(&args, lcppflgs);
+ applst(&args, cflags);
+ applst(&args, lcflags);
appcstrg(&args, name);
- appcstrg(&args, cppout);
- runchild(path, args, cppout);
+ /* we reuse the same tmp file for cpp output, so rewind and truncate */
+ if (lseek(cppoutfd, SEEK_SET, (off_t)0) != 0) {
+ warn("lseek");
+ terminate(-1);
+ }
+ if (ftruncate(cppoutfd, (off_t)0) != 0) {
+ warn("ftruncate");
+ terminate(-1);
+ }
+
+ runchild(path, args, cppout, cppoutfd);
free(path);
freelst(&args);
/* run lint1 */
- path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1"));
- (void)sprintf(path, "%s/lint1", PATH_LIBEXEC);
+ if (!Bflag) {
+ path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1") +
+ strlen(target_prefix));
+ (void)sprintf(path, "%s/%slint1", PATH_LIBEXEC,
+ target_prefix);
+ } else {
+ /*
+ * XXX Unclear whether we should be using target_prefix
+ * XXX here. --thorpej@wasabisystems.com
+ */
+ path = xmalloc(strlen(libexec_path) + sizeof ("/lint1"));
+ (void)sprintf(path, "%s/lint1", libexec_path);
+ }
appcstrg(&args, path);
applst(&args, l1flags);
appcstrg(&args, cppout);
appcstrg(&args, ofn);
- runchild(path, args, ofn);
+ runchild(path, args, ofn, -1);
free(path);
freelst(&args);
@@ -603,9 +696,7 @@ fname(name, last)
}
static void
-runchild(path, args, crfn)
- const char *path, *crfn;
- char *const *args;
+runchild(const char *path, char *const *args, const char *crfn, int fdout)
{
int status, rv, signo, i;
@@ -619,7 +710,7 @@ runchild(path, args, crfn)
(void)fflush(stdout);
- switch (fork()) {
+ switch (vfork()) {
case -1:
warn("cannot fork");
terminate(-1);
@@ -629,9 +720,15 @@ runchild(path, args, crfn)
break;
case 0:
/* child */
- (void)execv(path, args);
+
+ /* setup the standard output if necessary */
+ if (fdout != -1) {
+ dup2(fdout, STDOUT_FILENO);
+ close(fdout);
+ }
+ (void)execvp(path, args);
warn("cannot exec %s", path);
- exit(1);
+ _exit(1);
/* NOTREACHED */
}
@@ -642,7 +739,11 @@ runchild(path, args, crfn)
}
if (WIFSIGNALED(status)) {
signo = WTERMSIG(status);
+#if HAVE_DECL_SYS_SIGNAME
warnx("%s got SIG%s", path, sys_signame[signo]);
+#else
+ warnx("%s got signal %d", path, signo);
+#endif
terminate(-1);
}
if (WEXITSTATUS(status) != 0)
@@ -651,8 +752,7 @@ runchild(path, args, crfn)
}
static void
-findlibs(liblst)
- char *const *liblst;
+findlibs(char *const *liblst)
{
int i, k;
const char *lib, *path;
@@ -684,14 +784,13 @@ findlibs(liblst)
}
static int
-rdok(path)
- const char *path;
+rdok(const char *path)
{
struct stat sbuf;
if (stat(path, &sbuf) == -1)
return (0);
- if ((sbuf.st_mode & S_IFMT) != S_IFREG)
+ if (!S_ISREG(sbuf.st_mode))
return (0);
if (access(path, R_OK) == -1)
return (0);
@@ -699,30 +798,39 @@ rdok(path)
}
static void
-lint2()
+lint2(void)
{
char *path, **args;
args = xcalloc(1, sizeof (char *));
- path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint2"));
- (void)sprintf(path, "%s/lint2", PATH_LIBEXEC);
-
+ if (!Bflag) {
+ path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint2") +
+ strlen(target_prefix));
+ (void)sprintf(path, "%s/%slint2", PATH_LIBEXEC,
+ target_prefix);
+ } else {
+ /*
+ * XXX Unclear whether we should be using target_prefix
+ * XXX here. --thorpej@wasabisystems.com
+ */
+ path = xmalloc(strlen(libexec_path) + sizeof ("/lint2"));
+ (void)sprintf(path, "%s/lint2", libexec_path);
+ }
+
appcstrg(&args, path);
applst(&args, l2flags);
applst(&args, l2libs);
applst(&args, p2in);
- runchild(path, args, p2out);
+ runchild(path, args, p2out, -1);
free(path);
freelst(&args);
free(args);
}
static void
-cat(srcs, dest)
- char *const *srcs;
- const char *dest;
+cat(char *const *srcs, const char *dest)
{
int ifd, ofd, i;
char *src, *buf;
@@ -758,4 +866,3 @@ cat(srcs, dest)
(void)close(ofd);
free(buf);
}
-
OpenPOWER on IntegriCloud