Home | History | Annotate | Line # | Download | only in lint1
lint1.h revision 1.51
      1  1.51    rillig /* $NetBSD: lint1.h,v 1.51 2021/01/03 19:15:36 rillig Exp $ */
      2   1.2       cgd 
      3   1.1       cgd /*
      4   1.7       cgd  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
      5   1.1       cgd  * Copyright (c) 1994, 1995 Jochen Pohl
      6   1.1       cgd  * All Rights Reserved.
      7   1.1       cgd  *
      8   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      9   1.1       cgd  * modification, are permitted provided that the following conditions
     10   1.1       cgd  * are met:
     11   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     12   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     13   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     15   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     16   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     17   1.1       cgd  *    must display the following acknowledgement:
     18   1.1       cgd  *      This product includes software developed by Jochen Pohl for
     19   1.1       cgd  *	The NetBSD Project.
     20   1.1       cgd  * 4. The name of the author may not be used to endorse or promote products
     21   1.1       cgd  *    derived from this software without specific prior written permission.
     22   1.1       cgd  *
     23   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24   1.1       cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25   1.1       cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26   1.1       cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27   1.1       cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28   1.1       cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29   1.1       cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30   1.1       cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31   1.1       cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32   1.1       cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33   1.1       cgd  */
     34   1.1       cgd 
     35   1.1       cgd #include "lint.h"
     36  1.49    rillig #include "err-msgs.h"
     37   1.1       cgd #include "op.h"
     38  1.12        tv 
     39  1.25  christos /*
     40  1.25  christos  * XXX - Super conservative so that works for most systems, but we should
     41  1.25  christos  * not depend on the host settings but the target settings in determining
     42  1.25  christos  * the alignment. The only valid use for this is in mem1.c; uses in decl.c
     43  1.25  christos  * are bogus.
     44  1.25  christos  */
     45  1.25  christos #ifndef WORST_ALIGN
     46  1.25  christos #ifdef _LP64
     47  1.25  christos # define AVAL	15
     48  1.25  christos #else
     49  1.25  christos # define AVAL	7
     50  1.25  christos #endif
     51  1.25  christos #define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL)
     52  1.12        tv #endif
     53   1.1       cgd 
     54  1.27  christos #define LWARN_BAD	-3
     55  1.27  christos #define LWARN_ALL	-2
     56  1.27  christos #define LWARN_NONE	-1
     57  1.27  christos 
     58   1.1       cgd /*
     59   1.1       cgd  * Describes the position of a declaration or anything else.
     60   1.1       cgd  */
     61   1.1       cgd typedef struct {
     62   1.1       cgd 	int	p_line;
     63   1.1       cgd 	const	char *p_file;
     64   1.7       cgd 	int	p_uniq;			/* uniquifier */
     65   1.1       cgd } pos_t;
     66   1.7       cgd 
     67   1.7       cgd /* Copies curr_pos, keeping things unique. */
     68  1.34    rillig #define	UNIQUE_CURR_POS(pos)						\
     69  1.34    rillig 	do {								\
     70  1.45    rillig 		(pos) = curr_pos;					\
     71  1.34    rillig 		curr_pos.p_uniq++;					\
     72  1.34    rillig 		if (curr_pos.p_file == csrc_pos.p_file)			\
     73  1.34    rillig 			csrc_pos.p_uniq++;				\
     74  1.48    rillig 	} while (/*CONSTCOND*/0)
     75   1.1       cgd 
     76   1.1       cgd /*
     77   1.1       cgd  * Strings cannot be referenced to simply by a pointer to its first
     78   1.1       cgd  * char. This is because strings can contain NUL characters other than the
     79   1.1       cgd  * trailing NUL.
     80   1.1       cgd  *
     81   1.1       cgd  * Strings are stored with a trailing NUL.
     82   1.1       cgd  */
     83   1.1       cgd typedef	struct strg {
     84   1.1       cgd 	tspec_t	st_tspec;		/* CHAR or WCHAR */
     85   1.1       cgd 	size_t	st_len;			/* length without trailing NUL */
     86   1.1       cgd 	union {
     87   1.1       cgd 		u_char	*_st_cp;
     88   1.1       cgd 		wchar_t	*_st_wcp;
     89   1.1       cgd 	} st_u;
     90   1.1       cgd } strg_t;
     91   1.1       cgd 
     92   1.1       cgd #define st_cp	st_u._st_cp
     93   1.1       cgd #define	st_wcp	st_u._st_wcp
     94   1.1       cgd 
     95   1.1       cgd /*
     96   1.1       cgd  * qualifiers (only for lex/yacc interface)
     97   1.1       cgd  */
     98   1.1       cgd typedef enum {
     99  1.31  christos 	CONST, VOLATILE, RESTRICT, THREAD
    100   1.1       cgd } tqual_t;
    101   1.1       cgd 
    102   1.1       cgd /*
    103   1.1       cgd  * Integer and floating point values are stored in this structure
    104   1.1       cgd  */
    105   1.1       cgd typedef struct {
    106   1.1       cgd 	tspec_t	v_tspec;
    107   1.1       cgd 	int	v_ansiu;		/* set if an integer constant is
    108   1.1       cgd 					   unsigned in ANSI C */
    109   1.1       cgd 	union {
    110  1.13   thorpej 		int64_t	_v_quad;	/* integers */
    111   1.1       cgd 		ldbl_t	_v_ldbl;	/* floats */
    112   1.1       cgd 	} v_u;
    113   1.1       cgd } val_t;
    114   1.1       cgd 
    115   1.1       cgd #define v_quad	v_u._v_quad
    116   1.1       cgd #define v_ldbl	v_u._v_ldbl
    117   1.1       cgd 
    118   1.1       cgd /*
    119   1.1       cgd  * Structures of type str_t uniqely identify structures. This can't
    120   1.1       cgd  * be done in structures of type type_t, because these are copied
    121   1.1       cgd  * if they must be modified. So it would not be possible to check
    122  1.29  dholland  * if two structures are identical by comparing the pointers to
    123   1.1       cgd  * the type structures.
    124   1.1       cgd  *
    125   1.1       cgd  * The typename is used if the structure is unnamed to identify
    126   1.1       cgd  * the structure type in pass 2.
    127   1.1       cgd  */
    128   1.1       cgd typedef	struct {
    129   1.1       cgd 	u_int	size;		/* size in bit */
    130   1.1       cgd 	u_int	align : 15;	/* alignment in bit */
    131  1.47    rillig 	bool	sincompl : 1;	/* set if incomplete type */
    132   1.1       cgd 	struct	sym *memb;	/* list of members */
    133   1.1       cgd 	struct	sym *stag;	/* symbol table entry of tag */
    134   1.1       cgd 	struct	sym *stdef;	/* symbol table entry of first typename */
    135   1.1       cgd } str_t;
    136   1.1       cgd 
    137   1.1       cgd /*
    138   1.1       cgd  * same as above for enums
    139   1.1       cgd  */
    140   1.1       cgd typedef	struct {
    141  1.47    rillig 	bool	eincompl : 1;	/* incomplete enum type */
    142   1.1       cgd 	struct	sym *elem;	/* list of enumerators */
    143   1.1       cgd 	struct	sym *etag;	/* symbol table entry of tag */
    144   1.1       cgd 	struct	sym *etdef;	/* symbol table entry of first typename */
    145  1.26  christos } tenum_t;
    146   1.1       cgd 
    147   1.1       cgd /*
    148   1.1       cgd  * Types are represented by concatenation of structures of type type_t
    149   1.1       cgd  * via t_subt.
    150   1.1       cgd  */
    151  1.17  christos struct type {
    152   1.1       cgd 	tspec_t	t_tspec;	/* type specifier */
    153  1.47    rillig 	bool	t_aincompl : 1;	/* incomplete array type */
    154  1.47    rillig 	bool	t_const : 1;	/* const modifier */
    155  1.47    rillig 	bool	t_volatile : 1;	/* volatile modifier */
    156  1.47    rillig 	bool	t_proto : 1;	/* function prototype (t_args valid) */
    157  1.47    rillig 	bool	t_vararg : 1;	/* prototype with ... */
    158  1.47    rillig 	bool	t_typedef : 1;	/* type defined with typedef */
    159  1.50    rillig 	bool	t_bitfield : 1;
    160  1.47    rillig 	bool	t_isenum : 1;	/* type is (or was) enum (t_enum valid) */
    161  1.51    rillig 	bool	t_packed : 1;
    162   1.1       cgd 	union {
    163   1.1       cgd 		int	_t_dim;		/* dimension */
    164   1.1       cgd 		str_t	*_t_str;	/* struct/union tag */
    165  1.26  christos 		tenum_t	*_t_enum;	/* enum tag */
    166   1.1       cgd 		struct	sym *_t_args;	/* arguments (if t_proto) */
    167   1.1       cgd 	} t_u;
    168   1.8        pk 	struct {
    169   1.8        pk 		u_int	_t_flen : 8;	/* length of bit-field */
    170   1.8        pk 		u_int	_t_foffs : 24;	/* offset of bit-field */
    171   1.8        pk 	} t_b;
    172   1.1       cgd 	struct	type *t_subt;	/* element type (arrays), return value
    173   1.1       cgd 				   (functions), or type pointer points to */
    174  1.17  christos };
    175   1.1       cgd 
    176   1.1       cgd #define	t_dim	t_u._t_dim
    177   1.1       cgd #define	t_str	t_u._t_str
    178   1.1       cgd #define	t_enum	t_u._t_enum
    179   1.1       cgd #define	t_args	t_u._t_args
    180   1.8        pk #define	t_flen	t_b._t_flen
    181   1.8        pk #define	t_foffs	t_b._t_foffs
    182   1.1       cgd 
    183   1.1       cgd /*
    184   1.1       cgd  * types of symbols
    185   1.1       cgd  */
    186   1.1       cgd typedef	enum {
    187   1.1       cgd 	FVFT,		/* variables, functions, type names, enums */
    188  1.39    rillig 	FMEMBER,	/* members of structs or unions */
    189   1.1       cgd 	FTAG,		/* tags */
    190  1.39    rillig 	FLABEL		/* labels */
    191   1.1       cgd } symt_t;
    192   1.1       cgd 
    193   1.1       cgd /*
    194   1.1       cgd  * storage classes
    195   1.1       cgd  */
    196   1.1       cgd typedef enum {
    197   1.1       cgd 	NOSCL,
    198   1.1       cgd 	EXTERN,		/* external symbols (indep. of decl_t) */
    199   1.1       cgd 	STATIC,		/* static symbols (local and global) */
    200   1.1       cgd 	AUTO,		/* automatic symbols (except register) */
    201   1.1       cgd 	REG,		/* register */
    202   1.1       cgd 	TYPEDEF,	/* typedef */
    203   1.1       cgd 	STRTAG,
    204   1.1       cgd 	UNIONTAG,
    205   1.1       cgd 	ENUMTAG,
    206   1.1       cgd 	MOS,		/* member of struct */
    207   1.1       cgd 	MOU,		/* member of union */
    208  1.33    rillig 	ENUMCON,	/* enumerator, enum constant */
    209   1.1       cgd 	ABSTRACT,	/* abstract symbol (sizeof, casts, unnamed argument) */
    210   1.1       cgd 	ARG,		/* argument */
    211   1.4       jpo 	PARG,		/* used in declaration stack during prototype
    212   1.1       cgd 			   declaration */
    213   1.4       jpo 	INLINE		/* only used by the parser */
    214   1.1       cgd } scl_t;
    215   1.1       cgd 
    216   1.1       cgd /*
    217   1.1       cgd  * symbol table entry
    218   1.1       cgd  */
    219   1.1       cgd typedef	struct sym {
    220  1.33    rillig 	const	char *s_name;
    221   1.9       cgd 	const	char *s_rename;	/* renamed symbol's given name */
    222  1.44    rillig 	pos_t	s_def_pos;	/* position of last (prototype) definition,
    223  1.39    rillig 				   prototype declaration, no-prototype-def.,
    224   1.1       cgd 				   tentative definition or declaration,
    225   1.1       cgd 				   in this order */
    226  1.44    rillig 	pos_t	s_set_pos;	/* position of first initialisation */
    227  1.44    rillig 	pos_t	s_use_pos;	/* position of first use */
    228   1.1       cgd 	symt_t	s_kind;		/* type of symbol */
    229  1.43    rillig 	void   *s_keyword;
    230  1.47    rillig 	bool	s_bitfield : 1;
    231  1.47    rillig 	bool	s_set : 1;	/* variable set, label defined */
    232  1.47    rillig 	bool	s_used : 1;	/* variable/label used */
    233  1.47    rillig 	bool	s_arg : 1;	/* symbol is function argument */
    234  1.47    rillig 	bool	s_reg : 1;	/* symbol is register variable */
    235  1.47    rillig 	bool	s_defarg : 1;	/* undefined symbol in old style function
    236   1.1       cgd 				   definition */
    237  1.47    rillig 	bool	s_rimpl : 1;	/* return value of function implicit decl. */
    238  1.47    rillig 	bool	s_osdef : 1;	/* symbol stems from old style function def. */
    239  1.47    rillig 	bool	s_inline : 1;	/* true if this is an inline function */
    240  1.43    rillig 	struct	sym *s_ext_sym;	/* for local declared external symbols pointer
    241   1.1       cgd 				   to external symbol with same name */
    242   1.1       cgd 	def_t	s_def;		/* declared, tentative defined, defined */
    243   1.1       cgd 	scl_t	s_scl;		/* storage class */
    244   1.1       cgd 	int	s_blklev;	/* level of declaration, -1 if not in symbol
    245   1.1       cgd 				   table */
    246  1.33    rillig 	type_t	*s_type;
    247  1.33    rillig 	val_t	s_value;	/* value (if enum constant) */
    248   1.1       cgd 	union {
    249   1.1       cgd 		str_t	*_s_st;	/* tag, if it is a struct/union member */
    250  1.33    rillig 		tenum_t	*_s_et;	/* tag, if it is an enumerator */
    251   1.1       cgd 		tspec_t	_s_tsp;	/* type (only for keywords) */
    252   1.1       cgd 		tqual_t	_s_tqu;	/* qualifier (only for keywords) */
    253   1.1       cgd 		struct	sym *_s_args; /* arguments in old style function
    254   1.1       cgd 					 definitions */
    255   1.1       cgd 	} u;
    256   1.1       cgd 	struct	sym *s_link;	/* next symbol with same hash value */
    257   1.1       cgd 	struct	sym **s_rlink;	/* pointer to s_link of prev. symbol */
    258  1.38    rillig 	struct	sym *s_next;	/* next struct/union member, enumerator,
    259   1.1       cgd 				   argument */
    260  1.34    rillig 	struct	sym *s_dlnxt;	/* next symbol declared on same level */
    261   1.1       cgd } sym_t;
    262   1.1       cgd 
    263   1.1       cgd #define	s_styp	u._s_st
    264   1.1       cgd #define	s_etyp	u._s_et
    265   1.1       cgd #define	s_tspec	u._s_tsp
    266   1.1       cgd #define	s_tqual	u._s_tqu
    267   1.1       cgd #define	s_args	u._s_args
    268   1.1       cgd 
    269   1.1       cgd /*
    270  1.35    rillig  * Used to keep some information about symbols before they are entered
    271   1.1       cgd  * into the symbol table.
    272   1.1       cgd  */
    273   1.1       cgd typedef	struct sbuf {
    274   1.1       cgd 	const	char *sb_name;		/* name of symbol */
    275   1.1       cgd 	size_t	sb_len;			/* length (without '\0') */
    276   1.1       cgd 	int	sb_hash;		/* hash value */
    277   1.1       cgd 	sym_t	*sb_sym;		/* symbol table entry */
    278  1.40    rillig 	struct	sbuf *sb_next;		/* for freelist */
    279   1.1       cgd } sbuf_t;
    280   1.1       cgd 
    281   1.1       cgd 
    282   1.1       cgd /*
    283   1.1       cgd  * tree node
    284   1.1       cgd  */
    285   1.1       cgd typedef	struct tnode {
    286   1.1       cgd 	op_t	tn_op;		/* operator */
    287   1.1       cgd 	type_t	*tn_type;	/* type */
    288  1.47    rillig 	bool	tn_lvalue : 1;	/* node is lvalue */
    289  1.47    rillig 	bool	tn_cast : 1;	/* if tn_op == CVT, it's an explicit cast */
    290  1.47    rillig 	bool	tn_parenthesized : 1;
    291   1.1       cgd 	union {
    292   1.1       cgd 		struct {
    293   1.1       cgd 			struct	tnode *_tn_left;	/* (left) operand */
    294   1.1       cgd 			struct	tnode *_tn_right;	/* right operand */
    295   1.1       cgd 		} tn_s;
    296   1.1       cgd 		sym_t	*_tn_sym;	/* symbol if op == NAME */
    297   1.1       cgd 		val_t	*_tn_val;	/* value if op == CON */
    298  1.42    rillig 		strg_t	*_tn_string;	/* string if op == STRING */
    299   1.1       cgd 	} tn_u;
    300   1.1       cgd } tnode_t;
    301   1.1       cgd 
    302   1.1       cgd #define	tn_left	tn_u.tn_s._tn_left
    303   1.1       cgd #define tn_right tn_u.tn_s._tn_right
    304   1.1       cgd #define tn_sym	tn_u._tn_sym
    305   1.1       cgd #define	tn_val	tn_u._tn_val
    306  1.42    rillig #define	tn_string	tn_u._tn_string
    307   1.1       cgd 
    308   1.1       cgd /*
    309   1.1       cgd  * For nested declarations a stack exists, which holds all information
    310   1.1       cgd  * needed for the current level. dcs points to the top element of this
    311   1.1       cgd  * stack.
    312   1.1       cgd  *
    313   1.1       cgd  * ctx describes the context of the current declaration. Its value is
    314   1.1       cgd  * one of
    315   1.1       cgd  *	EXTERN	global declarations
    316   1.1       cgd  *	MOS oder MOU declarations of struct or union members
    317   1.1       cgd  *	ENUMCON	declarations of enums
    318   1.1       cgd  *	ARG	declaration of arguments in old style function definitions
    319   1.1       cgd  *	PARG	declaration of arguments in function prototypes
    320   1.1       cgd  *	AUTO	declaration of local symbols
    321   1.1       cgd  *	ABSTRACT abstract declarations (sizeof, casts)
    322   1.1       cgd  *
    323   1.1       cgd  */
    324   1.1       cgd typedef	struct dinfo {
    325  1.20  christos 	tspec_t	d_atyp;		/* VOID, CHAR, INT, or COMPLEX */
    326  1.20  christos 	tspec_t	d_cmod;		/* FLOAT, or DOUBLE */
    327   1.3       jpo 	tspec_t	d_smod;		/* SIGNED or UNSIGN */
    328   1.3       jpo 	tspec_t	d_lmod;		/* SHORT, LONG or QUAD */
    329   1.3       jpo 	scl_t	d_scl;		/* storage class */
    330   1.3       jpo 	type_t	*d_type;	/* after deftyp() pointer to the type used
    331   1.1       cgd 				   for all declarators */
    332   1.3       jpo 	sym_t	*d_rdcsym;	/* redeclared symbol */
    333   1.3       jpo 	int	d_offset;	/* offset of next structure member */
    334   1.3       jpo 	int	d_stralign;	/* alignment required for current structure */
    335   1.3       jpo 	scl_t	d_ctx;		/* context of declaration */
    336  1.47    rillig 	bool	d_const : 1;	/* const in declaration specifiers */
    337  1.47    rillig 	bool	d_volatile : 1;	/* volatile in declaration specifiers */
    338  1.47    rillig 	bool	d_inline : 1;	/* inline in declaration specifiers */
    339  1.47    rillig 	bool	d_mscl : 1;	/* multiple storage classes */
    340  1.47    rillig 	bool	d_terr : 1;	/* invalid type combination */
    341  1.47    rillig 	bool	d_nedecl : 1;	/* if at least one tag is declared */
    342  1.47    rillig 	bool	d_vararg : 1;	/* ... in in current function decl. */
    343  1.47    rillig 	bool	d_proto : 1;	/* current function decl. is prototype */
    344  1.47    rillig 	bool	d_notyp : 1;	/* set if no type specifier was present */
    345  1.47    rillig 	bool	d_asm : 1;	/* set if d_ctx == AUTO and asm() present */
    346  1.51    rillig 	bool	d_packed : 1;
    347  1.51    rillig 	bool	d_used : 1;
    348   1.3       jpo 	type_t	*d_tagtyp;	/* tag during member declaration */
    349   1.3       jpo 	sym_t	*d_fargs;	/* list of arguments during function def. */
    350   1.3       jpo 	pos_t	d_fdpos;	/* position of function definition */
    351   1.3       jpo 	sym_t	*d_dlsyms;	/* first symbol declared at this level */
    352   1.3       jpo 	sym_t	**d_ldlsym;	/* points to s_dlnxt in last symbol decl.
    353   1.1       cgd 				   at this level */
    354   1.3       jpo 	sym_t	*d_fpsyms;	/* symbols defined in prototype */
    355  1.41    rillig 	struct	dinfo *d_next;	/* next level */
    356   1.1       cgd } dinfo_t;
    357   1.1       cgd 
    358   1.1       cgd /*
    359   1.1       cgd  * Used to collect information about pointers and qualifiers in
    360   1.1       cgd  * declarators.
    361   1.1       cgd  */
    362   1.1       cgd typedef	struct pqinf {
    363   1.1       cgd 	int	p_pcnt;			/* number of asterisks */
    364  1.47    rillig 	bool	p_const : 1;
    365  1.47    rillig 	bool	p_volatile : 1;
    366  1.41    rillig 	struct	pqinf *p_next;
    367   1.1       cgd } pqinf_t;
    368   1.1       cgd 
    369   1.1       cgd /*
    370   1.1       cgd  * Case values are stored in a list of type clst_t.
    371   1.1       cgd  */
    372   1.1       cgd typedef	struct clst {
    373   1.1       cgd 	val_t	cl_val;
    374  1.40    rillig 	struct	clst *cl_next;
    375   1.1       cgd } clst_t;
    376   1.1       cgd 
    377   1.1       cgd /*
    378  1.35    rillig  * Used to keep information about nested control statements.
    379   1.1       cgd  */
    380   1.1       cgd typedef struct cstk {
    381   1.1       cgd 	int	c_env;			/* type of statement (T_IF, ...) */
    382  1.47    rillig 	bool	c_loop : 1;		/* continue && break are valid */
    383  1.47    rillig 	bool	c_switch : 1;		/* case && break are valid */
    384  1.47    rillig 	bool	c_break : 1;		/* loop/switch has break */
    385  1.47    rillig 	bool	c_cont : 1;		/* loop has continue */
    386  1.47    rillig 	bool	c_default : 1;		/* switch has default */
    387  1.47    rillig 	bool	c_infinite : 1;		/* break condition always false
    388   1.1       cgd 					   (for (;;), while (1)) */
    389  1.47    rillig 	bool	c_rchif : 1;		/* end of if-branch reached */
    390  1.47    rillig 	bool	c_noretval : 1;		/* had "return;" */
    391  1.47    rillig 	bool	c_retval : 1;		/* had "return (e);" */
    392   1.1       cgd 	type_t	*c_swtype;		/* type of switch expression */
    393   1.1       cgd 	clst_t	*c_clst;		/* list of case values */
    394   1.1       cgd 	struct	mbl *c_fexprm;		/* saved memory for end of loop
    395   1.1       cgd 					   expression in for() */
    396   1.1       cgd 	tnode_t	*c_f3expr;		/* end of loop expr in for() */
    397   1.1       cgd 	pos_t	c_fpos;			/* position of end of loop expr */
    398   1.1       cgd 	pos_t	c_cfpos;	        /* same for csrc_pos */
    399  1.40    rillig 	struct	cstk *c_next;		/* outer control statement */
    400   1.1       cgd } cstk_t;
    401   1.1       cgd 
    402  1.18  christos typedef struct {
    403  1.18  christos 	size_t lo;
    404  1.18  christos 	size_t hi;
    405  1.18  christos } range_t;
    406  1.18  christos 
    407   1.1       cgd #include "externs1.h"
    408  1.11  augustss 
    409  1.11  augustss #define	ERR_SETSIZE	1024
    410  1.11  augustss #define __NERRBITS (sizeof(unsigned int))
    411  1.11  augustss 
    412  1.11  augustss typedef	struct err_set {
    413  1.11  augustss 	unsigned int	errs_bits[(ERR_SETSIZE + __NERRBITS-1) / __NERRBITS];
    414  1.11  augustss } err_set;
    415  1.11  augustss 
    416  1.11  augustss #define	ERR_SET(n, p)	\
    417  1.34    rillig 	((p)->errs_bits[(n)/__NERRBITS] |= (1 << ((n) % __NERRBITS)))
    418  1.11  augustss #define	ERR_CLR(n, p)	\
    419  1.34    rillig 	((p)->errs_bits[(n)/__NERRBITS] &= ~(1 << ((n) % __NERRBITS)))
    420  1.11  augustss #define	ERR_ISSET(n, p)	\
    421  1.34    rillig 	((p)->errs_bits[(n)/__NERRBITS] & (1 << ((n) % __NERRBITS)))
    422  1.11  augustss #define	ERR_ZERO(p)	(void)memset((p), 0, sizeof(*(p)))
    423  1.14  christos 
    424  1.21  christos #define LERROR(fmt, args...)	lerror(__FILE__, __LINE__, fmt, ##args)
    425  1.11  augustss 
    426  1.37    rillig #define lint_assert(cond)						\
    427  1.37    rillig 	do {								\
    428  1.37    rillig 		if (!(cond))						\
    429  1.37    rillig 			assert_failed(__FILE__, __LINE__, __func__, #cond); \
    430  1.37    rillig 	} while (/*CONSTCOND*/0)
    431  1.37    rillig 
    432  1.28  christos #ifdef BLKDEBUG
    433  1.28  christos #define ZERO	0xa5
    434  1.28  christos #else
    435  1.28  christos #define	ZERO	0
    436  1.28  christos #endif
    437  1.28  christos 
    438  1.11  augustss extern err_set	msgset;
    439  1.49    rillig 
    440  1.49    rillig 
    441  1.49    rillig #ifdef DEBUG
    442  1.49    rillig #  include "err-msgs.h"
    443  1.49    rillig 
    444  1.49    rillig /* ARGSUSED */
    445  1.49    rillig static inline void __attribute__((format(printf, 1, 2)))
    446  1.49    rillig check_printf(const char *fmt, ...)
    447  1.49    rillig {
    448  1.49    rillig }
    449  1.49    rillig 
    450  1.49    rillig #  define wrap_check_printf(func, id, args...)				\
    451  1.49    rillig 	do {								\
    452  1.49    rillig 		check_printf(__CONCAT(MSG_, id), ##args);		\
    453  1.49    rillig 		(func)(id, ##args);					\
    454  1.49    rillig 	} while (/*CONSTCOND*/0)
    455  1.49    rillig 
    456  1.49    rillig #  define error(id, args...) wrap_check_printf(error, id, ##args)
    457  1.49    rillig #  define warning(id, args...) wrap_check_printf(warning, id, ##args)
    458  1.49    rillig #  define message(id, args...) wrap_check_printf(message, id, ##args)
    459  1.49    rillig #  define gnuism(id, args...) wrap_check_printf(gnuism, id, ##args)
    460  1.49    rillig #  define c99ism(id, args...) wrap_check_printf(c99ism, id, ##args)
    461  1.49    rillig #endif
    462