Permalink
Browse files

Remove xlint. It's outdated and there are much better checkers around.

clang static analyzer, cppcheck, coccinelle et al.

So there's no need to maintain it in base.
  • Loading branch information...
1 parent d8c83a8 commit 84f800532904979799aaeb8123487026f76a6640 Sascha Wildner committed Feb 5, 2013
Showing with 26 additions and 20,229 deletions.
  1. +6 −0 Makefile_upgrade.inc
  2. +1 −3 lib/libc/gen/dlsym.3
  3. +1 −9 share/man/man7/hier.7
  4. +17 −15 share/man/man9/style.9
  5. +0 −1 usr.bin/Makefile
  6. +1 −3 usr.bin/checknr/checknr.1
  7. +0 −7 usr.bin/xlint/Makefile
  8. +0 −3 usr.bin/xlint/Makefile.inc
  9. +0 −18 usr.bin/xlint/lint1/Makefile
  10. +0 −1,681 usr.bin/xlint/lint1/cgram.y
  11. +0 −3,050 usr.bin/xlint/lint1/decl.c
  12. +0 −227 usr.bin/xlint/lint1/emit.c
  13. +0 −573 usr.bin/xlint/lint1/emit1.c
  14. +0 −483 usr.bin/xlint/lint1/err.c
  15. +0 −58 usr.bin/xlint/lint1/externs.h
  16. +0 −284 usr.bin/xlint/lint1/externs1.h
  17. +0 −1,231 usr.bin/xlint/lint1/func.c
  18. +0 −508 usr.bin/xlint/lint1/init.c
  19. +0 −118 usr.bin/xlint/lint1/lint.h
  20. +0 −380 usr.bin/xlint/lint1/lint1.h
  21. +0 −180 usr.bin/xlint/lint1/main1.c
  22. +0 −84 usr.bin/xlint/lint1/mem.c
  23. +0 −342 usr.bin/xlint/lint1/mem1.c
  24. +0 −120 usr.bin/xlint/lint1/op.h
  25. +0 −114 usr.bin/xlint/lint1/param.h
  26. +0 −1,390 usr.bin/xlint/lint1/scan.l
  27. +0 −3,811 usr.bin/xlint/lint1/tree.c
  28. +0 −14 usr.bin/xlint/lint2/Makefile
  29. +0 −1,415 usr.bin/xlint/lint2/chk.c
  30. +0 −230 usr.bin/xlint/lint2/emit2.c
  31. +0 −89 usr.bin/xlint/lint2/externs2.h
  32. +0 −118 usr.bin/xlint/lint2/hash.c
  33. +0 −179 usr.bin/xlint/lint2/lint2.h
  34. +0 −186 usr.bin/xlint/lint2/main2.c
  35. +0 −94 usr.bin/xlint/lint2/mem2.c
  36. +0 −136 usr.bin/xlint/lint2/msg.c
  37. +0 −1,103 usr.bin/xlint/lint2/read.c
  38. +0 −22 usr.bin/xlint/llib/Makefile
  39. +0 −311 usr.bin/xlint/llib/llib-lposix
  40. +0 −252 usr.bin/xlint/llib/llib-lstdc
  41. +0 −14 usr.bin/xlint/xlint/Makefile
  42. +0 −565 usr.bin/xlint/xlint/lint.1
  43. +0 −42 usr.bin/xlint/xlint/pathnames.h
  44. +0 −766 usr.bin/xlint/xlint/xlint.c
View
6 Makefile_upgrade.inc
@@ -2119,6 +2119,12 @@ TO_REMOVE+=/usr/share/man/man3/liby.3.gz
TO_REMOVE+=/usr/bin/yyfix
TO_REMOVE+=/usr/share/man/cat1/yyfix.1.gz
TO_REMOVE+=/usr/share/man/man1/yyfix.1.gz
+TO_REMOVE+=/usr/bin/lint
+TO_REMOVE+=/usr/libdata/lint
+TO_REMOVE+=/usr/libexec/lint1
+TO_REMOVE+=/usr/libexec/lint2
+TO_REMOVE+=/usr/share/man/cat1/lint.1.gz
+TO_REMOVE+=/usr/share/man/man1/lint.1.gz
.if ${MACHINE_ARCH} == "x86_64"
TO_REMOVE+=/usr/sbin/stlstats
View
4 lib/libc/gen/dlsym.3
@@ -156,9 +156,7 @@ triggering compiler diagnostics.
function
returns a data pointer; in the C standard, conversions between
data and function pointer types are undefined.
-Some compilers and
-.Xr lint 1
-utilities warn about such casts.)
+Some compilers and code checkers warn about such casts.)
The precise return type of
.Fn dlfunc
is unspecified; applications must cast it to an appropriate function pointer
View
10 share/man/man7/hier.7
@@ -32,7 +32,7 @@
.\" @(#)hier.7 8.1 (Berkeley) 6/5/93
.\" $FreeBSD: src/share/man/man7/hier.7,v 1.29.2.17 2003/01/13 21:43:50 ceri Exp $
.\"
-.Dd September 11, 2012
+.Dd February 5, 2013
.Dt HIER 7
.Os
.Sh NAME
@@ -295,14 +295,6 @@ OpenSSL dynamic engines
.Pp
.It Pa libdata/
misc. utility data files
-.Pp
-.Bl -tag -width ".Pa lint/" -compact
-.It Pa lint/
-various prebuilt lint libraries;
-see
-.Xr lint 1
-.El
-.Pp
.It Pa libexec/
system daemons & system utilities (executed by other programs)
.Pp
View
32 share/man/man9/style.9
@@ -22,8 +22,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
+.\" Style guide for DragonFly. Based on the CSRG's KNF (Kernel Normal Form).
.\"
-.Dd August 30, 2004
+.\" @(#)style 1.14 (Berkeley) 4/28/95
+.\" $FreeBSD: src/share/man/man9/style.9,v 1.32.2.19 2002/04/14 19:28:03 asmodai Exp $
+.\"
+.Dd February 5, 2013
.Dt STYLE 9
.Os
.Sh NAME
@@ -40,14 +44,6 @@ Be careful to check the examples before assuming that
is silent on an issue.
.Bd -literal
/*
- * Style guide for DragonFly. Based on the CSRG's KNF (Kernel Normal Form).
- *
- * @(#)style 1.14 (Berkeley) 4/28/95
- * $FreeBSD: src/share/man/man9/style.9,v 1.32.2.19 2002/04/14 19:28:03 asmodai Exp $
- * $DragonFly: src/share/man/man9/style.9,v 1.21 2008/05/02 02:05:06 swildner Exp $
- */
-
-/*
* VERY important single-line comments look like this.
*/
@@ -745,15 +741,21 @@ KNF
.Nm
compliant in the repository must not diverge from compliance.
.Pp
-Whenever possible, code should be run through a code checker
-(e.g.,
-.Xr lint 1
+.Dx Ap s
+default warning options are a reasonable subset and -Werror is enabled for
+kernel and world, so passing
+.Cm buildworld
+or
+.Cm buildkernel
+alone is a good check.
+The warnings of most recent compilers are of high quality.
+Further analysis can be done using one of the various code checkers such as
+.Xr cppcheck 1
or
-.Nm gcc Fl Wall )
-and produce minimal warnings.
+.Xr clang 1 Ap s
+static analyzer.
.Sh SEE ALSO
.Xr indent 1 ,
-.Xr lint 1 ,
.Xr err 3 ,
.Xr sysexits 3 ,
.Xr warn 3
View
1 usr.bin/Makefile
@@ -236,7 +236,6 @@ SUBDIR= alias \
write \
xargs \
xinstall \
- xlint \
xstr \
xz \
xzdec \
View
4 usr.bin/checknr/checknr.1
@@ -31,7 +31,6 @@
.\"
.\" @(#)checknr.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD: src/usr.bin/checknr/checknr.1,v 1.5.2.5 2002/07/15 04:29:39 keramida Exp $
-.\" $DragonFly: src/usr.bin/checknr/checknr.1,v 1.4 2006/02/17 19:38:57 swildner Exp $
.\"
.Dd June 6, 1993
.Dt CHECKNR 1
@@ -102,8 +101,7 @@ The
.Nm
utility is intended for use on documents that are prepared with
.Nm
-in mind, much the same as
-.Xr lint 1 .
+in mind.
It expects a certain document writing style for
.Ql \ef
and
View
7 usr.bin/xlint/Makefile
@@ -1,7 +0,0 @@
-# $NetBSD: Makefile,v 1.2 1995/07/03 21:23:45 cgd Exp $
-# $FreeBSD: src/usr.bin/xlint/Makefile,v 1.7 2000/01/16 08:25:39 sheldonh Exp $
-# $DragonFly: src/usr.bin/xlint/Makefile,v 1.2 2003/06/17 04:29:34 dillon Exp $
-
-SUBDIR= lint1 lint2 xlint #llib
-
-.include <bsd.subdir.mk>
View
3 usr.bin/xlint/Makefile.inc
@@ -1,3 +0,0 @@
-WARNS?= 1
-
-.include "../Makefile.inc"
View
18 usr.bin/xlint/lint1/Makefile
@@ -1,18 +0,0 @@
-# $NetBSD: Makefile,v 1.3 1995/07/04 01:53:05 cgd Exp $
-# $FreeBSD: src/usr.bin/xlint/lint1/Makefile,v 1.7.2.1 2000/12/07 16:33:35 obrien Exp $
-
-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 y.tab.h
-NOMAN=
-LDADD+= -ll
-DPADD+= ${LIBL}
-CFLAGS+= -I. -I${.CURDIR}
-LINTFLAGS=-aehpz
-
-BINDIR= /usr/libexec
-
-# XXX: -O causes the gcc to die on the i386, when compiling tree.o
-CFLAGS+= -DXXX_BROKEN_GCC
-
-.include <bsd.prog.mk>
View
1,681 usr.bin/xlint/lint1/cgram.y
@@ -1,1681 +0,0 @@
-%{
-/* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo 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.
- *
- * $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $
- * $DragonFly: src/usr.bin/xlint/lint1/cgram.y,v 1.6 2004/07/07 12:26:51 asmodai Exp $
- */
-
-#include <stdlib.h>
-#include <limits.h>
-
-#include "lint1.h"
-
-/*
- * Contains the level of current declaration. 0 is extern.
- * Used for symbol table entries.
- */
-int blklev;
-
-/*
- * level for memory allocation. Normaly the same as blklev.
- * An exeption is the declaration of arguments in prototypes. Memory
- * for these can't be freed after the declaration, but symbols must
- * be removed from the symbol table after the declaration.
- */
-int mblklev;
-
-static int toicon(tnode_t *);
-static void idecl(sym_t *, int);
-static void ignuptorp(void);
-
-%}
-
-%union {
- int y_int;
- val_t *y_val;
- sbuf_t *y_sb;
- sym_t *y_sym;
- op_t y_op;
- scl_t y_scl;
- tspec_t y_tspec;
- tqual_t y_tqual;
- type_t *y_type;
- tnode_t *y_tnode;
- strg_t *y_strg;
- pqinf_t *y_pqinf;
-};
-
-%token T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPARN T_RPARN
-%token <y_op> T_STROP
-%token <y_op> T_UNOP
-%token <y_op> T_INCDEC
-%token T_SIZEOF
-%token <y_op> T_MULT
-%token <y_op> T_DIVOP
-%token <y_op> T_ADDOP
-%token <y_op> T_SHFTOP
-%token <y_op> T_RELOP
-%token <y_op> T_EQOP
-%token <y_op> T_AND
-%token <y_op> T_XOR
-%token <y_op> T_OR
-%token <y_op> T_LOGAND
-%token <y_op> T_LOGOR
-%token T_QUEST
-%token T_COLON
-%token <y_op> T_ASSIGN
-%token <y_op> T_OPASS
-%token T_COMMA
-%token T_SEMI
-%token T_ELLIPSE
-
-/* storage classes (extern, static, auto, register and typedef) */
-%token <y_scl> T_SCLASS
-
-/* types (char, int, short, long, unsigned, signed, float, double, void) */
-%token <y_tspec> T_TYPE
-
-/* qualifiers (const, volatile) */
-%token <y_tqual> T_QUAL
-
-/* struct or union */
-%token <y_tspec> T_SOU
-
-/* enum */
-%token T_ENUM
-
-/* remaining keywords */
-%token T_CASE
-%token T_DEFAULT
-%token T_IF
-%token T_ELSE
-%token T_SWITCH
-%token T_DO
-%token T_WHILE
-%token T_FOR
-%token T_GOTO
-%token T_CONTINUE
-%token T_BREAK
-%token T_RETURN
-%token T_ASM
-
-%left T_COMMA
-%right T_ASSIGN T_OPASS
-%right T_QUEST T_COLON
-%left T_LOGOR
-%left T_LOGAND
-%left T_OR
-%left T_XOR
-%left T_AND
-%left T_EQOP
-%left T_RELOP
-%left T_SHFTOP
-%left T_ADDOP
-%left T_MULT T_DIVOP
-%right T_UNOP T_INCDEC T_SIZEOF
-%left T_LPARN T_LBRACK T_STROP
-
-%token <y_sb> T_NAME
-%token <y_sb> T_TYPENAME
-%token <y_val> T_CON
-%token <y_strg> T_STRING
-
-%type <y_sym> func_decl
-%type <y_sym> notype_decl
-%type <y_sym> type_decl
-%type <y_type> typespec
-%type <y_type> clrtyp_typespec
-%type <y_type> notype_typespec
-%type <y_type> struct_spec
-%type <y_type> enum_spec
-%type <y_sym> struct_tag
-%type <y_sym> enum_tag
-%type <y_tspec> struct
-%type <y_sym> struct_declaration
-%type <y_sb> identifier
-%type <y_sym> member_declaration_list_with_rbrace
-%type <y_sym> member_declaration_list
-%type <y_sym> member_declaration
-%type <y_sym> notype_member_decls
-%type <y_sym> type_member_decls
-%type <y_sym> notype_member_decl
-%type <y_sym> type_member_decl
-%type <y_tnode> constant
-%type <y_sym> enum_declaration
-%type <y_sym> enums_with_opt_comma
-%type <y_sym> enums
-%type <y_sym> enumerator
-%type <y_sym> ename
-%type <y_sym> notype_direct_decl
-%type <y_sym> type_direct_decl
-%type <y_pqinf> pointer
-%type <y_pqinf> asterisk
-%type <y_sym> param_decl
-%type <y_sym> param_list
-%type <y_sym> abs_decl_param_list
-%type <y_sym> direct_param_decl
-%type <y_sym> notype_param_decl
-%type <y_sym> direct_notype_param_decl
-%type <y_pqinf> type_qualifier_list
-%type <y_pqinf> type_qualifier
-%type <y_sym> identifier_list
-%type <y_sym> abs_decl
-%type <y_sym> direct_abs_decl
-%type <y_sym> vararg_parameter_type_list
-%type <y_sym> parameter_type_list
-%type <y_sym> parameter_declaration
-%type <y_tnode> expr
-%type <y_tnode> term
-%type <y_tnode> func_arg_list
-%type <y_op> point_or_arrow
-%type <y_type> type_name
-%type <y_sym> abstract_declaration
-%type <y_tnode> do_while_expr
-%type <y_tnode> opt_expr
-%type <y_strg> string
-%type <y_strg> string2
-
-
-%%
-
-program:
- /* empty */ {
- if (sflag) {
- /* empty translation unit */
- error(272);
- } else if (!tflag) {
- /* empty translation unit */
- warning(272);
- }
- }
- | translation_unit
- ;
-
-translation_unit:
- ext_decl
- | translation_unit ext_decl
- ;
-
-ext_decl:
- func_def {
- glclup(0);
- clrwflgs();
- }
- | data_def {
- glclup(0);
- clrwflgs();
- }
- ;
-
-data_def:
- T_SEMI {
- if (sflag) {
- /* syntax error: empty declaration */
- error(0);
- } else if (!tflag) {
- /* syntax error: empty declaration */
- warning(0);
- }
- }
- | clrtyp deftyp notype_init_decls T_SEMI {
- if (sflag) {
- /* old style declaration; add "int" */
- error(1);
- } else if (!tflag) {
- /* old style declaration; add "int" */
- warning(1);
- }
- }
- | declmods deftyp T_SEMI {
- if (dcs->d_scl == TYPEDEF) {
- /* typedef declares no type name */
- warning(72);
- } else {
- /* empty declaration */
- warning(2);
- }
- }
- | declmods deftyp notype_init_decls T_SEMI
- | declspecs deftyp T_SEMI {
- if (dcs->d_scl == TYPEDEF) {
- /* typedef declares no type name */
- warning(72);
- } else if (!dcs->d_nedecl) {
- /* empty declaration */
- warning(2);
- }
- }
- | declspecs deftyp type_init_decls T_SEMI
- | error T_SEMI {
- globclup();
- }
- | error T_RBRACE {
- globclup();
- }
- ;
-
-func_def:
- func_decl {
- if ($1->s_type->t_tspec != FUNC) {
- /* syntax error */
- error(249);
- YYERROR;
- }
- if ($1->s_type->t_typedef) {
- /* ()-less function definition */
- error(64);
- YYERROR;
- }
- funcdef($1);
- blklev++;
- pushdecl(ARG);
- } opt_arg_declaration_list {
- popdecl();
- blklev--;
- cluparg();
- pushctrl(0);
- } comp_stmnt {
- funcend();
- popctrl(0);
- }
- ;
-
-func_decl:
- clrtyp deftyp notype_decl {
- $$ = $3;
- }
- | declmods deftyp notype_decl {
- $$ = $3;
- }
- | declspecs deftyp type_decl {
- $$ = $3;
- }
- ;
-
-opt_arg_declaration_list:
- /* empty */
- | arg_declaration_list
- ;
-
-arg_declaration_list:
- arg_declaration
- | arg_declaration_list arg_declaration
- /* XXX or better "arg_declaration error" ? */
- | error
- ;
-
-/*
- * "arg_declaration" is separated from "declaration" because it
- * needs other error handling.
- */
-
-arg_declaration:
- declmods deftyp T_SEMI {
- /* empty declaration */
- warning(2);
- }
- | declmods deftyp notype_init_decls T_SEMI
- | declspecs deftyp T_SEMI {
- if (!dcs->d_nedecl) {
- /* empty declaration */
- warning(2);
- } else {
- tspec_t ts = dcs->d_type->t_tspec;
- /* %s declared in argument declaration list */
- warning(3, ts == STRUCT ? "struct" :
- (ts == UNION ? "union" : "enum"));
- }
- }
- | declspecs deftyp type_init_decls T_SEMI {
- if (dcs->d_nedecl) {
- tspec_t ts = dcs->d_type->t_tspec;
- /* %s declared in argument declaration list */
- warning(3, ts == STRUCT ? "struct" :
- (ts == UNION ? "union" : "enum"));
- }
- }
- | declmods error
- | declspecs error
- ;
-
-declaration:
- declmods deftyp T_SEMI {
- if (dcs->d_scl == TYPEDEF) {
- /* typedef declares no type name */
- warning(72);
- } else {
- /* empty declaration */
- warning(2);
- }
- }
- | declmods deftyp notype_init_decls T_SEMI
- | declspecs deftyp T_SEMI {
- if (dcs->d_scl == TYPEDEF) {
- /* typedef declares no type name */
- warning(72);
- } else if (!dcs->d_nedecl) {
- /* empty declaration */
- warning(2);
- }
- }
- | declspecs deftyp type_init_decls T_SEMI
- | error T_SEMI
- ;
-
-clrtyp:
- {
- clrtyp();
- }
- ;
-
-deftyp:
- /* empty */ {
- deftyp();
- }
- ;
-
-declspecs:
- clrtyp_typespec {
- addtype($1);
- }
- | declmods typespec {
- addtype($2);
- }
- | declspecs declmod
- | declspecs notype_typespec {
- addtype($2);
- }
- ;
-
-declmods:
- clrtyp T_QUAL {
- addqual($2);
- }
- | clrtyp T_SCLASS {
- addscl($2);
- }
- | declmods declmod
- ;
-
-declmod:
- T_QUAL {
- addqual($1);
- }
- | T_SCLASS {
- addscl($1);
- }
- ;
-
-clrtyp_typespec:
- clrtyp notype_typespec {
- $$ = $2;
- }
- | T_TYPENAME clrtyp {
- $$ = getsym($1)->s_type;
- }
- ;
-
-typespec:
- notype_typespec {
- $$ = $1;
- }
- | T_TYPENAME {
- $$ = getsym($1)->s_type;
- }
- ;
-
-notype_typespec:
- T_TYPE {
- $$ = gettyp($1);
- }
- | struct_spec {
- popdecl();
- $$ = $1;
- }
- | enum_spec {
- popdecl();
- $$ = $1;
- }
- ;
-
-struct_spec:
- struct struct_tag {
- /*
- * STDC requires that "struct a;" always introduces
- * a new tag if "a" is not declared at current level
- *
- * yychar is valid because otherwise the parser would
- * not been able to deceide if he must shift or reduce
- */
- $$ = mktag($2, $1, 0, yychar == T_SEMI);
- }
- | struct struct_tag {
- dcs->d_tagtyp = mktag($2, $1, 1, 0);
- } struct_declaration {
- $$ = compltag(dcs->d_tagtyp, $4);
- }
- | struct {
- dcs->d_tagtyp = mktag(NULL, $1, 1, 0);
- } struct_declaration {
- $$ = compltag(dcs->d_tagtyp, $3);
- }
- | struct error {
- symtyp = FVFT;
- $$ = gettyp(INT);
- }
- ;
-
-struct:
- T_SOU {
- symtyp = FTAG;
- pushdecl($1 == STRUCT ? MOS : MOU);
- dcs->d_offset = 0;
- dcs->d_stralign = CHAR_BIT;
- $$ = $1;
- }
- ;
-
-struct_tag:
- identifier {
- $$ = getsym($1);
- }
- ;
-
-struct_declaration:
- struct_decl_lbrace member_declaration_list_with_rbrace {
- $$ = $2;
- }
- ;
-
-struct_decl_lbrace:
- T_LBRACE {
- symtyp = FVFT;
- }
- ;
-
-member_declaration_list_with_rbrace:
- member_declaration_list T_SEMI T_RBRACE {
- $$ = $1;
- }
- | member_declaration_list T_RBRACE {
- if (sflag) {
- /* syntax req. ";" after last struct/union member */
- error(66);
- } else {
- /* syntax req. ";" after last struct/union member */
- warning(66);
- }
- $$ = $1;
- }
- | T_RBRACE {
- $$ = NULL;
- }
- ;
-
-member_declaration_list:
- member_declaration {
- $$ = $1;
- }
- | member_declaration_list T_SEMI member_declaration {
- $$ = lnklst($1, $3);
- }
- ;
-
-member_declaration:
- noclass_declmods deftyp {
- /* too late, i know, but getsym() compensates it */
- symtyp = FMOS;
- } notype_member_decls {
- symtyp = FVFT;
- $$ = $4;
- }
- | noclass_declspecs deftyp {
- symtyp = FMOS;
- } type_member_decls {
- symtyp = FVFT;
- $$ = $4;
- }
- | noclass_declmods deftyp {
- /* struct or union member must be named */
- warning(49);
- $$ = NULL;
- }
- | noclass_declspecs deftyp {
- /* struct or union member must be named */
- warning(49);
- $$ = NULL;
- }
- | error {
- symtyp = FVFT;
- $$ = NULL;
- }
- ;
-
-noclass_declspecs:
- clrtyp_typespec {
- addtype($1);
- }
- | noclass_declmods typespec {
- addtype($2);
- }
- | noclass_declspecs T_QUAL {
- addqual($2);
- }
- | noclass_declspecs notype_typespec {
- addtype($2);
- }
- ;
-
-noclass_declmods:
- clrtyp T_QUAL {
- addqual($2);
- }
- | noclass_declmods T_QUAL {
- addqual($2);
- }
- ;
-
-notype_member_decls:
- notype_member_decl {
- $$ = decl1str($1);
- }
- | notype_member_decls {
- symtyp = FMOS;
- } T_COMMA type_member_decl {
- $$ = lnklst($1, decl1str($4));
- }
- ;
-
-type_member_decls:
- type_member_decl {
- $$ = decl1str($1);
- }
- | type_member_decls {
- symtyp = FMOS;
- } T_COMMA type_member_decl {
- $$ = lnklst($1, decl1str($4));
- }
- ;
-
-notype_member_decl:
- notype_decl {
- $$ = $1;
- }
- | notype_decl T_COLON constant {
- $$ = bitfield($1, toicon($3));
- }
- | {
- symtyp = FVFT;
- } T_COLON constant {
- $$ = bitfield(NULL, toicon($3));
- }
- ;
-
-type_member_decl:
- type_decl {
- $$ = $1;
- }
- | type_decl T_COLON constant {
- $$ = bitfield($1, toicon($3));
- }
- | {
- symtyp = FVFT;
- } T_COLON constant {
- $$ = bitfield(NULL, toicon($3));
- }
- ;
-
-enum_spec:
- enum enum_tag {
- $$ = mktag($2, ENUM, 0, 0);
- }
- | enum enum_tag {
- dcs->d_tagtyp = mktag($2, ENUM, 1, 0);
- } enum_declaration {
- $$ = compltag(dcs->d_tagtyp, $4);
- }
- | enum {
- dcs->d_tagtyp = mktag(NULL, ENUM, 1, 0);
- } enum_declaration {
- $$ = compltag(dcs->d_tagtyp, $3);
- }
- | enum error {
- symtyp = FVFT;
- $$ = gettyp(INT);
- }
- ;
-
-enum:
- T_ENUM {
- symtyp = FTAG;
- pushdecl(ENUMCON);
- }
- ;
-
-enum_tag:
- identifier {
- $$ = getsym($1);
- }
- ;
-
-enum_declaration:
- enum_decl_lbrace enums_with_opt_comma T_RBRACE {
- $$ = $2;
- }
- ;
-
-enum_decl_lbrace:
- T_LBRACE {
- symtyp = FVFT;
- enumval = 0;
- }
- ;
-
-enums_with_opt_comma:
- enums {
- $$ = $1;
- }
- | enums T_COMMA {
- if (sflag) {
- /* trailing "," prohibited in enum declaration */
- error(54);
- } else {
- /* trailing "," prohibited in enum declaration */
- warning(54);
- }
- $$ = $1;
- }
- ;
-
-enums:
- enumerator {
- $$ = $1;
- }
- | enums T_COMMA enumerator {
- $$ = lnklst($1, $3);
- }
- | error {
- $$ = NULL;
- }
- ;
-
-enumerator:
- ename {
- $$ = ename($1, enumval, 1);
- }
- | ename T_ASSIGN constant {
- $$ = ename($1, toicon($3), 0);
- }
- ;
-
-ename:
- identifier {
- $$ = getsym($1);
- }
- ;
-
-
-notype_init_decls:
- notype_init_decl
- | notype_init_decls T_COMMA type_init_decl
- ;
-
-type_init_decls:
- type_init_decl
- | type_init_decls T_COMMA type_init_decl
- ;
-
-notype_init_decl:
- notype_decl opt_asm_spec {
- idecl($1, 0);
- chksz($1);
- }
- | notype_decl opt_asm_spec {
- idecl($1, 1);
- } T_ASSIGN initializer {
- chksz($1);
- }
- ;
-
-type_init_decl:
- type_decl opt_asm_spec {
- idecl($1, 0);
- chksz($1);
- }
- | type_decl opt_asm_spec {
- idecl($1, 1);
- } T_ASSIGN initializer {
- chksz($1);
- }
- ;
-
-notype_decl:
- notype_direct_decl {
- $$ = $1;
- }
- | pointer notype_direct_decl {
- $$ = addptr($2, $1);
- }
- ;
-
-notype_direct_decl:
- T_NAME {
- $$ = dname(getsym($1));
- }
- | T_LPARN type_decl T_RPARN {
- $$ = $2;
- }
- | notype_direct_decl T_LBRACK T_RBRACK {
- $$ = addarray($1, 0, 0);
- }
- | notype_direct_decl T_LBRACK constant T_RBRACK {
- $$ = addarray($1, 1, toicon($3));
- }
- | notype_direct_decl param_list {
- $$ = addfunc($1, $2);
- popdecl();
- blklev--;
- }
- ;
-
-type_decl:
- type_direct_decl {
- $$ = $1;
- }
- | pointer type_direct_decl {
- $$ = addptr($2, $1);
- }
- ;
-
-type_direct_decl:
- identifier {
- $$ = dname(getsym($1));
- }
- | T_LPARN type_decl T_RPARN {
- $$ = $2;
- }
- | type_direct_decl T_LBRACK T_RBRACK {
- $$ = addarray($1, 0, 0);
- }
- | type_direct_decl T_LBRACK constant T_RBRACK {
- $$ = addarray($1, 1, toicon($3));
- }
- | type_direct_decl param_list {
- $$ = addfunc($1, $2);
- popdecl();
- blklev--;
- }
- ;
-
-/*
- * param_decl and notype_param_decl exist to avoid a conflict in
- * argument lists. A typename enclosed in parens should always be
- * treated as a typename, not an argument.
- * "typedef int a; f(int (a));" is "typedef int a; f(int foo(a));"
- * not "typedef int a; f(int a);"
- */
-param_decl:
- direct_param_decl {
- $$ = $1;
- }
- | pointer direct_param_decl {
- $$ = addptr($2, $1);
- }
- ;
-
-direct_param_decl:
- identifier {
- $$ = dname(getsym($1));
- }
- | T_LPARN notype_param_decl T_RPARN {
- $$ = $2;
- }
- | direct_param_decl T_LBRACK T_RBRACK {
- $$ = addarray($1, 0, 0);
- }
- | direct_param_decl T_LBRACK constant T_RBRACK {
- $$ = addarray($1, 1, toicon($3));
- }
- | direct_param_decl param_list {
- $$ = addfunc($1, $2);
- popdecl();
- blklev--;
- }
- ;
-
-notype_param_decl:
- direct_notype_param_decl {
- $$ = $1;
- }
- | pointer direct_notype_param_decl {
- $$ = addptr($2, $1);
- }
- ;
-
-direct_notype_param_decl:
- T_NAME {
- $$ = dname(getsym($1));
- }
- | T_LPARN notype_param_decl T_RPARN {
- $$ = $2;
- }
- | direct_notype_param_decl T_LBRACK T_RBRACK {
- $$ = addarray($1, 0, 0);
- }
- | direct_notype_param_decl T_LBRACK constant T_RBRACK {
- $$ = addarray($1, 1, toicon($3));
- }
- | direct_notype_param_decl param_list {
- $$ = addfunc($1, $2);
- popdecl();
- blklev--;
- }
- ;
-
-pointer:
- asterisk {
- $$ = $1;
- }
- | asterisk type_qualifier_list {
- $$ = mergepq($1, $2);
- }
- | asterisk pointer {
- $$ = mergepq($1, $2);
- }
- | asterisk type_qualifier_list pointer {
- $$ = mergepq(mergepq($1, $2), $3);
- }
- ;
-
-asterisk:
- T_MULT {
- $$ = xcalloc(1, sizeof (pqinf_t));
- $$->p_pcnt = 1;
- }
- ;
-
-type_qualifier_list:
- type_qualifier {
- $$ = $1;
- }
- | type_qualifier_list type_qualifier {
- $$ = mergepq($1, $2);
- }
- ;
-
-type_qualifier:
- T_QUAL {
- $$ = xcalloc(1, sizeof (pqinf_t));
- if ($1 == CONST) {
- $$->p_const = 1;
- } else {
- $$->p_volatile = 1;
- }
- }
- ;
-
-param_list:
- id_list_lparn identifier_list T_RPARN {
- $$ = $2;
- }
- | abs_decl_param_list {
- $$ = $1;
- }
- ;
-
-id_list_lparn:
- T_LPARN {
- blklev++;
- pushdecl(PARG);
- }
- ;
-
-identifier_list:
- T_NAME {
- $$ = iname(getsym($1));
- }
- | identifier_list T_COMMA T_NAME {
- $$ = lnklst($1, iname(getsym($3)));
- }
- | identifier_list error {
- $$ = $1;
- }
- ;
-
-abs_decl_param_list:
- abs_decl_lparn T_RPARN {
- $$ = NULL;
- }
- | abs_decl_lparn vararg_parameter_type_list T_RPARN {
- dcs->d_proto = 1;
- $$ = $2;
- }
- | abs_decl_lparn error T_RPARN {
- $$ = NULL;
- }
- ;
-
-abs_decl_lparn:
- T_LPARN {
- blklev++;
- pushdecl(PARG);
- }
- ;
-
-vararg_parameter_type_list:
- parameter_type_list {
- $$ = $1;
- }
- | parameter_type_list T_COMMA T_ELLIPSE {
- dcs->d_vararg = 1;
- $$ = $1;
- }
- | T_ELLIPSE {
- if (sflag) {
- /* ANSI C requires formal parameter before "..." */
- error(84);
- } else if (!tflag) {
- /* ANSI C requires formal parameter before "..." */
- warning(84);
- }
- dcs->d_vararg = 1;
- $$ = NULL;
- }
- ;
-
-parameter_type_list:
- parameter_declaration opt_asm_spec {
- $$ = $1;
- }
- | parameter_type_list T_COMMA parameter_declaration opt_asm_spec {
- $$ = lnklst($1, $3);
- }
- ;
-
-parameter_declaration:
- declmods deftyp {
- $$ = decl1arg(aname(), 0);
- }
- | declspecs deftyp {
- $$ = decl1arg(aname(), 0);
- }
- | declmods deftyp notype_param_decl {
- $$ = decl1arg($3, 0);
- }
- /*
- * param_decl is needed because of following conflict:
- * "typedef int a; f(int (a));" could be parsed as
- * "function with argument a of type int", or
- * "function with an abstract argument of type function".
- * This grammar realizes the second case.
- */
- | declspecs deftyp param_decl {
- $$ = decl1arg($3, 0);
- }
- | declmods deftyp abs_decl {
- $$ = decl1arg($3, 0);
- }
- | declspecs deftyp abs_decl {
- $$ = decl1arg($3, 0);
- }
- ;
-
-opt_asm_spec:
- /* empty */
- | T_ASM T_LPARN T_STRING T_RPARN {
- freeyyv(&$3, T_STRING);
- }
- ;
-
-initializer:
- init_expr
- ;
-
-init_expr:
- expr %prec T_COMMA {
- mkinit($1);
- }
- | init_lbrace init_expr_list init_rbrace
- | init_lbrace init_expr_list T_COMMA init_rbrace
- | error
- ;
-
-init_expr_list:
- init_expr %prec T_COMMA
- | init_expr_list T_COMMA init_expr
- ;
-
-init_lbrace:
- T_LBRACE {
- initlbr();
- }
- ;
-
-init_rbrace:
- T_RBRACE {
- initrbr();
- }
- ;
-
-type_name:
- {
- pushdecl(ABSTRACT);
- } abstract_declaration {
- popdecl();
- $$ = $2->s_type;
- }
- ;
-
-abstract_declaration:
- noclass_declmods deftyp {
- $$ = decl1abs(aname());
- }
- | noclass_declspecs deftyp {
- $$ = decl1abs(aname());
- }
- | noclass_declmods deftyp abs_decl {
- $$ = decl1abs($3);
- }
- | noclass_declspecs deftyp abs_decl {
- $$ = decl1abs($3);
- }
- ;
-
-abs_decl:
- pointer {
- $$ = addptr(aname(), $1);
- }
- | direct_abs_decl {
- $$ = $1;
- }
- | pointer direct_abs_decl {
- $$ = addptr($2, $1);
- }
- ;
-
-direct_abs_decl:
- T_LPARN abs_decl T_RPARN {
- $$ = $2;
- }
- | T_LBRACK T_RBRACK {
- $$ = addarray(aname(), 0, 0);
- }
- | T_LBRACK constant T_RBRACK {
- $$ = addarray(aname(), 1, toicon($2));
- }
- | direct_abs_decl T_LBRACK T_RBRACK {
- $$ = addarray($1, 0, 0);
- }
- | direct_abs_decl T_LBRACK constant T_RBRACK {
- $$ = addarray($1, 1, toicon($3));
- }
- | abs_decl_param_list {
- $$ = addfunc(aname(), $1);
- popdecl();
- blklev--;
- }
- | direct_abs_decl abs_decl_param_list {
- $$ = addfunc($1, $2);
- popdecl();
- blklev--;
- }
- ;
-
-stmnt:
- labeled_stmnt
- | expr_stmnt
- | comp_stmnt
- | selection_stmnt
- | iteration_stmnt
- | jump_stmnt {
- ftflg = 0;
- }
- | asm_stmnt
- ;
-
-labeled_stmnt:
- label stmnt
- ;
-
-label:
- identifier T_COLON {
- symtyp = FLAB;
- label(T_NAME, getsym($1), NULL);
- }
- | T_CASE constant T_COLON {
- label(T_CASE, NULL, $2);
- ftflg = 1;
- }
- | T_DEFAULT T_COLON {
- label(T_DEFAULT, NULL, NULL);
- ftflg = 1;
- }
- ;
-
-comp_stmnt:
- compstmnt_lbrace declaration_list opt_stmnt_list compstmnt_rbrace
- | compstmnt_lbrace opt_stmnt_list compstmnt_rbrace
- ;
-
-compstmnt_lbrace:
- T_LBRACE {
- blklev++;
- mblklev++;
- pushdecl(AUTO);
- }
- ;
-
-compstmnt_rbrace:
- T_RBRACE {
- popdecl();
- freeblk();
- mblklev--;
- blklev--;
- ftflg = 0;
- }
- ;
-
-opt_stmnt_list:
- /* empty */
- | stmnt_list
- ;
-
-stmnt_list:
- stmnt {
- clrwflgs();
- }
- | stmnt_list stmnt {
- clrwflgs();
- }
- | stmnt_list error T_SEMI {
- clrwflgs();
- }
- ;
-
-expr_stmnt:
- expr T_SEMI {
- expr($1, 0, 0);
- ftflg = 0;
- }
- | T_SEMI {
- ftflg = 0;
- }
- ;
-
-selection_stmnt:
- if_without_else {
- if2();
- if3(0);
- }
- | if_without_else T_ELSE {
- if2();
- } stmnt {
- if3(1);
- }
- | if_without_else T_ELSE error {
- if3(0);
- }
- | switch_expr stmnt {
- switch2();
- }
- | switch_expr error {
- switch2();
- }
- ;
-
-if_without_else:
- if_expr stmnt
- | if_expr error
- ;
-
-if_expr:
- T_IF T_LPARN expr T_RPARN {
- if1($3);
- clrwflgs();
- }
- ;
-
-switch_expr:
- T_SWITCH T_LPARN expr T_RPARN {
- switch1($3);
- clrwflgs();
- }
- ;
-
-iteration_stmnt:
- while_expr stmnt {
- while2();
- }
- | while_expr error {
- while2();
- }
- | do stmnt do_while_expr {
- do2($3);
- ftflg = 0;
- }
- | do error {
- do2(NULL);
- }
- | for_exprs stmnt {
- for2();
- }
- | for_exprs error {
- for2();
- }
- ;
-
-while_expr:
- T_WHILE T_LPARN expr T_RPARN {
- while1($3);
- clrwflgs();
- }
- ;
-
-do:
- T_DO {
- do1();
- }
- ;
-
-do_while_expr:
- T_WHILE T_LPARN expr T_RPARN T_SEMI {
- $$ = $3;
- }
- ;
-
-for_exprs:
- T_FOR T_LPARN opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPARN {
- for1($3, $5, $7);
- clrwflgs();
- }
- ;
-
-opt_expr:
- /* empty */ {
- $$ = NULL;
- }
- | expr {
- $$ = $1;
- }
- ;
-
-jump_stmnt:
- goto identifier T_SEMI {
- dogoto(getsym($2));
- }
- | goto error T_SEMI {
- symtyp = FVFT;
- }
- | T_CONTINUE T_SEMI {
- docont();
- }
- | T_BREAK T_SEMI {
- dobreak();
- }
- | T_RETURN T_SEMI {
- doreturn(NULL);
- }
- | T_RETURN expr T_SEMI {
- doreturn($2);
- }
- ;
-
-goto:
- T_GOTO {
- symtyp = FLAB;
- }
- ;
-
-asm_stmnt:
- T_ASM T_LPARN read_until_rparn T_SEMI {
- setasm();
- }
- | T_ASM T_QUAL T_LPARN read_until_rparn T_SEMI {
- setasm();
- }
- | T_ASM error
- ;
-
-read_until_rparn:
- /* empty */ {
- ignuptorp();
- }
- ;
-
-declaration_list:
- declaration {
- clrwflgs();
- }
- | declaration_list declaration {
- clrwflgs();
- }
- ;
-
-constant:
- expr %prec T_COMMA {
- $$ = $1;
- }
- ;
-
-expr:
- expr T_MULT expr {
- $$ = build(MULT, $1, $3);
- }
- | expr T_DIVOP expr {
- $$ = build($2, $1, $3);
- }
- | expr T_ADDOP expr {
- $$ = build($2, $1, $3);
- }
- | expr T_SHFTOP expr {
- $$ = build($2, $1, $3);
- }
- | expr T_RELOP expr {
- $$ = build($2, $1, $3);
- }
- | expr T_EQOP expr {
- $$ = build($2, $1, $3);
- }
- | expr T_AND expr {
- $$ = build(AND, $1, $3);
- }
- | expr T_XOR expr {
- $$ = build(XOR, $1, $3);
- }
- | expr T_OR expr {
- $$ = build(OR, $1, $3);
- }
- | expr T_LOGAND expr {
- $$ = build(LOGAND, $1, $3);
- }
- | expr T_LOGOR expr {
- $$ = build(LOGOR, $1, $3);
- }
- | expr T_QUEST expr T_COLON expr {
- $$ = build(QUEST, $1, build(COLON, $3, $5));
- }
- | expr T_ASSIGN expr {
- $$ = build(ASSIGN, $1, $3);
- }
- | expr T_OPASS expr {
- $$ = build($2, $1, $3);
- }
- | expr T_COMMA expr {
- $$ = build(COMMA, $1, $3);
- }
- | term {
- $$ = $1;
- }
- ;
-
-term:
- T_NAME {
- /* XXX realy neccessary? */
- if (yychar < 0)
- yychar = yylex();
- $$ = getnnode(getsym($1), yychar);
- }
- | string {
- $$ = getsnode($1);
- }
- | T_CON {
- $$ = getcnode(gettyp($1->v_tspec), $1);
- }
- | T_LPARN expr T_RPARN {
- if ($2 != NULL)
- $2->tn_parn = 1;
- $$ = $2;
- }
- | term T_INCDEC {
- $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
- }
- | T_INCDEC term {
- $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL);
- }
- | T_MULT term {
- $$ = build(STAR, $2, NULL);
- }
- | T_AND term {
- $$ = build(AMPER, $2, NULL);
- }
- | T_UNOP term {
- $$ = build($1, $2, NULL);
- }
- | T_ADDOP term {
- if (tflag && $1 == PLUS) {
- /* unary + is illegal in traditional C */
- warning(100);
- }
- $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL);
- }
- | term T_LBRACK expr T_RBRACK {
- $$ = build(STAR, build(PLUS, $1, $3), NULL);
- }
- | term T_LPARN T_RPARN {
- $$ = funccall($1, NULL);
- }
- | term T_LPARN func_arg_list T_RPARN {
- $$ = funccall($1, $3);
- }
- | term point_or_arrow T_NAME {
- if ($1 != NULL) {
- sym_t *msym;
- /* XXX strmemb should be integrated in build() */
- if ($2 == ARROW) {
- /* must to this before strmemb is called */
- $1 = cconv($1);
- }
- msym = strmemb($1, $2, getsym($3));
- $$ = build($2, $1, getnnode(msym, 0));
- } else {
- $$ = NULL;
- }
- }
- | T_SIZEOF term %prec T_SIZEOF {
- if (($$ = $2 == NULL ? NULL : bldszof($2->tn_type)) != NULL)
- chkmisc($2, 0, 0, 0, 0, 0, 1);
- }
- | T_SIZEOF T_LPARN type_name T_RPARN %prec T_SIZEOF {
- $$ = bldszof($3);
- }
- | T_LPARN type_name T_RPARN term %prec T_UNOP {
- $$ = cast($4, $2);
- }
- ;
-
-string:
- T_STRING {
- $$ = $1;
- }
- | T_STRING string2 {
- $$ = catstrg($1, $2);
- }
- ;
-
-string2:
- T_STRING {
- if (tflag) {
- /* concatenated strings are illegal in traditional C */
- warning(219);
- }
- $$ = $1;
- }
- | string2 T_STRING {
- $$ = catstrg($1, $2);
- }
- ;
-
-func_arg_list:
- expr %prec T_COMMA {
- $$ = funcarg(NULL, $1);
- }
- | func_arg_list T_COMMA expr {
- $$ = funcarg($1, $3);
- }
- ;
-
-point_or_arrow:
- T_STROP {
- symtyp = FMOS;
- $$ = $1;
- }
- ;
-
-identifier:
- T_NAME {
- $$ = $1;
- }
- | T_TYPENAME {
- $$ = $1;
- }
- ;
-
-%%
-
-/* ARGSUSED */
-int
-yyerror(char *msg)
-{
- error(249);
- if (++sytxerr >= 5)
- norecover();
- return (0);
-}
-
-/*
- * Gets a node for a constant and returns the value of this constant
- * as integer.
- * Is the node not constant or too large for int or of type float,
- * a warning will be printed.
- *
- * toicon() should be used only inside declarations. If it is used in
- * expressions, it frees the memory used for the expression.
- */
-static int
-toicon(tnode_t *tn)
-{
- int i;
- tspec_t t;
- val_t *v;
-
- v = constant(tn);
-
- /*
- * Abstract declarations are used inside expression. To free
- * the memory would be a fatal error.
- */
- if (dcs->d_ctx != ABSTRACT)
- tfreeblk();
-
- if ((t = v->v_tspec) == FLOAT || t == DOUBLE || t == LDOUBLE) {
- i = (int)v->v_ldbl;
- /* integral constant expression expected */
- error(55);
- } else {
- i = (int)v->v_quad;
- if (isutyp(t)) {
- if ((u_quad_t)v->v_quad > INT_MAX) {
- /* integral constant too large */
- warning(56);
- }
- } else {
-#ifdef XXX_BROKEN_GCC
- if (v->v_quad > INT_MAX) {
- /* integral constant too large */
- warning(56);
- }
- else if (v->v_quad < INT_MIN) {
- /* integral constant too large */
- warning(56);
- }
-#else
- if (v->v_quad > INT_MAX || v->v_quad < INT_MIN) {
- /* integral constant too large */
- warning(56);
- }
-#endif
- }
- }
- free(v);
- return (i);
-}
-
-static void
-idecl(sym_t *decl, int initflg)
-{
- initerr = 0;
- initsym = decl;
-
- switch (dcs->d_ctx) {
- case EXTERN:
- decl1ext(decl, initflg);
- break;
- case ARG:
- (void)decl1arg(decl, initflg);
- break;
- case AUTO:
- decl1loc(decl, initflg);
- break;
- default:
- lerror("idecl()");
- }
-
- if (initflg && !initerr)
- prepinit();
-}
-
-/*
- * Discard all input tokens up to and including the next
- * unmatched right paren
- */
-void
-ignuptorp(void)
-{
- int level;
-
- if (yychar < 0)
- yychar = yylex();
- freeyyv(&yylval, yychar);
-
- level = 1;
- while (yychar != T_RPARN || --level > 0) {
- if (yychar == T_LPARN) {
- level++;
- } else if (yychar <= 0) {
- break;
- }
- freeyyv(&yylval, yychar = yylex());
- }
-
- yyclearin;
-}
View
3,050 usr.bin/xlint/lint1/decl.c
0 additions, 3,050 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
227 usr.bin/xlint/lint1/emit.c
@@ -1,227 +0,0 @@
-/* $NetBSD: emit.c,v 1.2 1995/07/03 21:24:00 cgd 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.
- *
- * $FreeBSD: src/usr.bin/xlint/lint1/emit.c,v 1.1.1.1.8.1 2001/03/04 09:27:26 kris Exp $
- * $DragonFly: src/usr.bin/xlint/lint1/emit.c,v 1.5 2004/07/07 12:13:26 asmodai Exp $
- *
- * $NetBSD: emit.c,v 1.2 1995/07/03 21:24:00 cgd Exp $
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <err.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;
-
- /* Ausgabedatei oeffnen */
- if ((lout = fopen(name, "w")) == NULL)
- err(1, "cannot open '%s'", name);
-
- /* Ausgabepuffer anlegen */
- 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);
-}
View
573 usr.bin/xlint/lint1/emit1.c
@@ -1,573 +0,0 @@
-/* $NetBSD: emit1.c,v 1.4 1995/10/02 17:21:28 jpo 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.
- *
- * $NetBSD: emit1.c,v 1.4 1995/10/02 17:21:28 jpo Exp $
- * $DragonFly: src/usr.bin/xlint/lint1/emit1.c,v 1.5 2004/07/07 12:13:26 asmodai Exp $
- */
-
-#include <ctype.h>
-
-#include "lint1.h"
-
-static void outtt(sym_t *, sym_t *);
-static void outfstrg(strg_t *);
-
-/*
- * Write type into the output buffer.
- * The type is written as a sequence of substrings, each of which describes a
- * node of type type_t
- * a node is coded as follows:
- * char C
- * signed char s C
- * unsigned char u C
- * short S
- * unsigned short u S
- * int I
- * unsigned int u I
- * long L
- * unsigned long u L
- * long long Q
- * unsigned long long u Q
- * float s D
- * double D
- * long double l D
- * void V
- * * P
- * [n] A n
- * () F
- * (void) F 0
- * (n arguments) F n arg1 arg2 ... argn
- * (n arguments, ...) F n arg1 arg2 ... argn-1 E
- * (a, b, c, ...) f n arg1 arg2 ...
- * enum tag e T tag_or_typename
- * struct tag s T tag_or_typename
- * union tag u T tag_or_typename
- *
- * tag_or_typename 0 no tag or type name
- * 1 n tag Tag
- * 2 n typename only type name
- *
- * spaces are only for better readability
- * additionaly it is possible to prepend the characters 'c' (for const)
- * and 'v' (for volatile)
- */
-void
-outtype(type_t *tp)
-{
- int t, s, na;
- sym_t *arg;
- tspec_t ts;
-
- while (tp != NULL) {
- if ((ts = tp->t_tspec) == INT && tp->t_isenum)
- ts = ENUM;
- switch (ts) {
- case CHAR: t = 'C'; s = '\0'; break;
- case SCHAR: t = 'C'; s = 's'; break;
- case UCHAR: t = 'C'; s = 'u'; break;
- case SHORT: t = 'S'; s = '\0'; break;
- case USHORT: t = 'S'; s = 'u'; break;
- case INT: t = 'I'; s = '\0'; break;
- case UINT: t = 'I'; s = 'u'; break;
- case LONG: t = 'L'; s = '\0'; break;
- case ULONG: t = 'L'; s = 'u'; break;
- case QUAD: t = 'Q'; s = '\0'; break;
- case UQUAD: t = 'Q'; s = 'u'; break;
- case FLOAT: t = 'D'; s = 's'; break;
- case DOUBLE: t = 'D'; s = '\0'; break;
- case LDOUBLE: t = 'D'; s = 'l'; break;
- case VOID: t = 'V'; s = '\0'; break;
- case PTR: t = 'P'; s = '\0'; break;
- case ARRAY: t = 'A'; s = '\0'; break;
- case FUNC: t = 'F'; s = '\0'; break;
- case ENUM: t = 'T'; s = 'e'; break;
- case STRUCT: t = 'T'; s = 's'; break;
- case UNION: t = 'T'; s = 'u'; break;
- default:
- lerror("outtyp() 1");
- }
- if (tp->t_const)
- outchar('c');
- if (tp->t_volatile)
- outchar('v');
- if (s != '\0')
- outchar(s);
- outchar(t);
- if (ts == ARRAY) {
- outint(tp->t_dim);
- } else if (ts == ENUM) {
- outtt(tp->t_enum->etag, tp->t_enum->etdef);
- } else if (ts == STRUCT || ts == UNION) {
- outtt(tp->t_str->stag, tp->t_str->stdef);
- } else if (ts == FUNC && tp->t_proto) {
- na = 0;
- for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt)
- na++;
- if (tp->t_vararg)
- na++;
- outint(na);
- for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt)
- outtype(arg->s_type);
- if (tp->t_vararg)
- outchar('E');
- }
- tp = tp->t_subt;
- }
-}
-
-/*
- * type to string
- * used for debugging output
- *
- * it uses its own output buffer for conversion
- */
-const char *
-ttos(type_t *tp)
-{
- static ob_t tob;
- ob_t tmp;
-
- if (tob.o_buf == NULL) {
- tob.o_len = 64;
- tob.o_buf = tob.o_nxt = xmalloc(tob.o_len);
- tob.o_end = tob.o_buf + tob.o_len;
- }
-
- tmp = ob;
- ob = tob;
- ob.o_nxt = ob.o_buf;
- outtype(tp);
- outchar('\0');
- tob = ob;
- ob = tmp;
-
- return (tob.o_buf);
-}
-
-/*
- * write the name of a tag or typename
- *
- * if the tag is named, the name of the
- * tag is written, otherwise, if a typename exists which
- * refers to this tag, this typename is written
- */
-static void
-outtt(sym_t *tag, sym_t *tdef)
-{
- if (tag->s_name != unnamed) {
- outint(1);
- outname(tag->s_name);
- } else if (tdef != NULL) {
- outint(2);
- outname(tdef->s_name);
- } else {
- outint(0);
- }
-}
-
-/*
- * write information about an global declared/defined symbol
- * with storage class extern
- *
- * informations about function definitions are written in outfdef(),
- * not here
- */
-void
-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
- * and extern functions) must be checked in lint2. Lint1 can't do
- * this, especially not, if functions are declared at block level
- * before their first declaration at level 0.
- */
- if (sc != EXTERN && !(sc == STATIC && sym->s_type->t_tspec == FUNC))
- return;
-
- /* reset buffer */
- outclr();
-
- /*
- * line number of .c source, 'd' for declaration, Id of current
- * source (.c or .h), and line in current source.
- */
- outint(csrc_pos.p_line);
- outchar('d');
- outint(getfnid(sym->s_dpos.p_file));
- outchar('.');
- outint(sym->s_dpos.p_line);
-
- /* flags */
-
- switch (def) {
- case DEF:
- /* defined */
- outchar('d');
- break;
- case TDEF:
- /* tentative defined */
- outchar('t');
- break;
- case DECL:
- /* declared */
- outchar('e');
- break;
- default:
- lerror("outsym() 2");
- }
- if (llibflg && def != DECL) {
- /*
- * mark it as used so we get no warnings from lint2 about
- * unused symbols in libraries.
- */
- outchar('u');
- }
-
- if (sc == STATIC)
- outchar('s');
-
- /* name of the symbol */
- outname(sym->s_name);
-
- /* type of the symbol */
- outtype(sym->s_type);
-}
-
-/*
- * write information about function definition
- *
- * this is also done for static functions so we are able to check if
- * they are called with proper argument types
- */
-void
-outfdef(sym_t *fsym, pos_t *posp, int rval, int osdef, sym_t *args)
-{
- int narg;
- sym_t *arg;
-
- /* reset the buffer */
- outclr();
-
- /*
- * line number of .c source, 'd' for declaration, Id of current
- * source (.c or .h), and line in current source
- *
- * we are already at the end of the function. If we are in the
- * .c source, posp->p_line is correct, otherwise csrc_pos.p_line
- * (for functions defined in header files).
- */
- if (posp->p_file == csrc_pos.p_file) {
- outint(posp->p_line);
- } else {
- outint(csrc_pos.p_line);
- }
- outchar('d');
- outint(getfnid(posp->p_file));
- outchar('.');
- outint(posp->p_line);
-
- /* flags */
-
- /* both SCANFLIKE and PRINTFLIKE imply VARARGS */
- if (prflstrg != -1) {
- nvararg = prflstrg;
- } else if (scflstrg != -1) {
- nvararg = scflstrg;
- }
-
- if (nvararg != -1) {
- outchar('v');
- outint(nvararg);
- }
- if (scflstrg != -1) {
- outchar('S');
- outint(scflstrg);
- }
- if (prflstrg != -1) {
- outchar('P');
- outint(prflstrg);
- }
- nvararg = prflstrg = scflstrg = -1;
-
- outchar('d');
-
- if (rval)
- /* has return value */
- outchar('r');
-
- if (llibflg)
- /*
- * mark it as used so lint2 does not complain about
- * unused symbols in libraries
- */
- outchar('u');
-
- if (osdef)
- /* old style function definition */
- outchar('o');
-
- if (fsym->s_scl == STATIC)
- outchar('s');
-
- /* name of function */
- outname(fsym->s_name);
-
- /* argument types and return value */
- if (osdef) {
- narg = 0;
- for (arg = args; arg != NULL; arg = arg->s_nxt)
- narg++;
- outchar('f');
- outint(narg);
- for (arg = args; arg != NULL; arg = arg->s_nxt)
- outtype(arg->s_type);
- outtype(fsym->s_type->t_subt);
- } else {
- outtype(fsym->s_type);
- }
-}
-
-/*
- * write out all information necessary for lint2 to check function
- * calls
- *
- * rvused is set if the return value is used (asigned to a variable)
- * rvdisc is set if the return value is not used and not ignored
- * (casted to void)
- */
-void
-outcall(tnode_t *tn, int rvused, int rvdisc)
-{
- tnode_t *args, *arg;
- int narg, n, i;
- quad_t q;
- tspec_t t;
-
- /* reset buffer */
- outclr();
-
- /*
- * line number of .c source, 'c' for function call, Id of current
- * source (.c or .h), and line in current source
- */
- outint(csrc_pos.p_line);
- outchar('c');
- outint(getfnid(curr_pos.p_file));
- outchar('.');
- outint(curr_pos.p_line);
-
- /*
- * flags; 'u' and 'i' must be last to make sure a letter
- * is between the numeric argument of a flag and the name of
- * the function
- */
- narg = 0;
- args = tn->tn_right;
- for (arg = args; arg != NULL; arg = arg->tn_right)
- narg++;
- /* 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) ;
- arg = arg->tn_left;
- if (arg->tn_op == CON) {
- if (isityp(t = arg->tn_type->t_tspec)) {
- /*
- * XXX it would probably be better to
- * explizitly test the sign
- */
- if ((q = arg->tn_val->v_quad) == 0) {
- /* zero constant */
- outchar('z');
- } else if (msb(q, t, 0) == 0) {
- /* positive if casted to signed */
- outchar('p');
- } else {
- /* negative if casted to signed */
- outchar('n');
- }
- outint(n);
- }
- } else if (arg->tn_op == AMPER &&
- arg->tn_left->tn_op == STRING &&
- arg->tn_left->tn_strg->st_tspec == CHAR) {
- /* constant string, write all format specifiers */
- outchar('s');
- outint(n);
- outfstrg(arg->tn_left->tn_strg);
- }
-
- }
- /* return value discarded/used/ignored */
- outchar(rvdisc ? 'd' : (rvused ? 'u' : 'i'));
-
- /* name of the called function */
- outname(tn->tn_left->tn_left->tn_sym->s_name);
-
- /* types of arguments */
- outchar('f');
- 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) ;
- outtype(arg->tn_left->tn_type);
- }
- /* expected type of return value */
- outtype(tn->tn_type);
-}
-
-/*
- * extracts potential format specifiers for printf() and scanf() and
- * writes them, enclosed in "" and qouted if necessary, to the output buffer
- */
-static void
-outfstrg(strg_t *strg)
-{
- int c, oc, first;
- u_char *cp;
-
- if (strg->st_tspec != CHAR)
- lerror("outfstrg() 1");
-
- cp = strg->st_cp;
-
- outchar('"');
-
- c = *cp++;
-
- while (c != '\0') {
-
- if (c != '%') {
- c = *cp++;
- continue;
- }
-
- outqchar('%');
- c = *cp++;
-
- /* flags for printf and scanf and *-fieldwidth for printf */
- while (c != '\0' && (c == '-' || c == '+' || c == ' ' ||
- c == '#' || c == '0' || c == '*')) {
- outqchar(c);
- c = *cp++;
- }
-
- /* numeric field width */
- while (c != '\0' && isdigit(c)) {
- outqchar(c);
- c = *cp++;
- }
-
- /* precision for printf */
- if (c == '.') {
- outqchar(c);
- if ((c = *cp++) == '*') {
- outqchar(c);
- c = *cp++;
- } else {
- while (c != '\0' && isdigit(c)) {
- outqchar(c);
- c = *cp++;
- }
- }
- }
-
- /* h, l, L and q flags fpr printf and scanf */
- if (c == 'h' || c == 'l' || c == 'L' || c == 'q') {
- outqchar(c);
- c = *cp++;
- }
-
- /*
- * The last character. It is always written so we can detect
- * invalid format specifiers.
- */
- if (c != '\0') {
- outqchar(c);
- oc = c;
- c = *cp++;
- /*
- * handle [ for scanf. [-] means that a minus sign
- * was found at an undefined position.
- */
- if (oc == '[') {
- if (c == '^')
- c = *cp++;
- if (c == ']')
- c = *cp++;
- first = 1;
- while (c != '\0' && c != ']') {
- if (c == '-') {
- if (!first && *cp != ']')