summaryrefslogtreecommitdiff
path: root/warning.h
blob: dde254d942a7b4caed9036effc17827c60b575ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
   This file is built by warning.pl
   Any changes made here will be lost!
*/


#define Off(x)                  ((x) / 8)
#define Bit(x)                  (1 << ((x) % 8))
#define IsSet(a, x)		((a)[Off(x)] & Bit(x))

#define G_WARN_OFF		0 	/* $^W == 0 */
#define G_WARN_ON		1	/* $^W != 0 */
#define G_WARN_ALL_ON		2	/* -W flag */
#define G_WARN_ALL_OFF		4	/* -X flag */
#define G_WARN_ALL_MASK		(G_WARN_ALL_ON|G_WARN_ALL_OFF)

#if 1

/* Part of the logic below assumes that WARN_NONE is NULL */

#define ckDEAD(x)							\
	   (PL_curcop->cop_warnings != WARN_ALL &&			\
	    PL_curcop->cop_warnings != WARN_NONE &&			\
	    IsSet(SvPVX(PL_curcop->cop_warnings), 2*x+1))

#define ckWARN(x)							\
	( (PL_curcop->cop_warnings &&					\
	      (PL_curcop->cop_warnings == WARN_ALL ||			\
	       IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) ) )		\
	  || (PL_dowarn & G_WARN_ON) )

#define ckWARN2(x,y)							\
	  ( (PL_curcop->cop_warnings &&					\
	      (PL_curcop->cop_warnings == WARN_ALL ||			\
	        IsSet(SvPVX(PL_curcop->cop_warnings), 2*x)  ||		\
	        IsSet(SvPVX(PL_curcop->cop_warnings), 2*y) ) ) 		\
	    ||	(PL_dowarn & G_WARN_ON) )

#else

#define ckDEAD(x)							\
	   (PL_curcop->cop_warnings != WARN_ALL &&			\
	    PL_curcop->cop_warnings != WARN_NONE &&			\
	    SvPVX(PL_curcop->cop_warnings)[Off(2*x+1)] & Bit(2*x+1) )

#define ckWARN(x)							\
	( (PL_dowarn & G_WARN_ON) || ( (PL_dowarn & G_WARN_DISABLE) && 	\
	  PL_curcop->cop_warnings &&					\
	  ( PL_curcop->cop_warnings == WARN_ALL ||			\
	    SvPVX(PL_curcop->cop_warnings)[Off(2*x)] & Bit(2*x)  ) ) )

#define ckWARN2(x,y)							\
	( (PL_dowarn & G_WARN_ON) || ( (PL_dowarn & G_WARN_DISABLE) && 	\
	  PL_curcop->cop_warnings &&					\
	  ( PL_curcop->cop_warnings == WARN_ALL ||			\
	    SvPVX(PL_curcop->cop_warnings)[Off(2*x)] & Bit(2*x) || 	\
	    SvPVX(PL_curcop->cop_warnings)[Off(2*y)] & Bit(2*y) ) ) ) 

#endif

#define WARN_NONE		NULL
#define WARN_ALL		(&PL_sv_yes)

#define WARN_DEFAULT		0
#define WARN_IO			1
#define WARN_CLOSED		2
#define WARN_EXEC		3
#define WARN_NEWLINE		4
#define WARN_PIPE		5
#define WARN_UNOPENED		6
#define WARN_MISC		7
#define WARN_NUMERIC		8
#define WARN_ONCE		9
#define WARN_RECURSION		10
#define WARN_REDEFINE		11
#define WARN_SYNTAX		12
#define WARN_AMBIGUOUS		13
#define WARN_DEPRECATED		14
#define WARN_OCTAL		15
#define WARN_PARENTHESIS	16
#define WARN_PRECEDENCE		17
#define WARN_PRINTF		18
#define WARN_RESERVED		19
#define WARN_SEMICOLON		20
#define WARN_UNINITIALIZED	21
#define WARN_UNSAFE		22
#define WARN_CLOSURE		23
#define WARN_SIGNAL		24
#define WARN_SUBSTR		25
#define WARN_TAINT		26
#define WARN_UNTIE		27
#define WARN_UTF8		28
#define WARN_VOID		29

#define WARNsize		8
#define WARN_ALLstring		"\125\125\125\125\125\125\125\125"
#define WARN_NONEstring		"\0\0\0\0\0\0\0\0"

/* end of file warning.h */