directive-elif.mk revision 1.7 1 1.7 rillig # $NetBSD: directive-elif.mk,v 1.7 2020/12/19 19:49:01 rillig Exp $
2 1.1 rillig #
3 1.2 rillig # Tests for the .elif directive.
4 1.7 rillig #
5 1.7 rillig # Misspellings of the .elif directive are not always detected. They are only
6 1.7 rillig # detected if the conditional branch directly above it is taken. In all other
7 1.7 rillig # cases, make skips over the skipped branch as fast as possible, looking only
8 1.7 rillig # at the initial '.' of the line and whether the directive is one of the known
9 1.7 rillig # conditional directives. All other directives are silently ignored, as they
10 1.7 rillig # could be variable assignments or dependency declarations as well, and
11 1.7 rillig # deciding this would cost time.
12 1.7 rillig
13 1.1 rillig
14 1.1 rillig # TODO: Implementation
15 1.1 rillig
16 1.7 rillig
17 1.7 rillig # Misspelling '.elsif' below an .if branch that is not taken.
18 1.7 rillig .if 0
19 1.7 rillig . info This branch is not taken.
20 1.7 rillig # As of 2020-12-19, the misspelling is not recognized as a conditional
21 1.7 rillig # directive and is thus silently skipped.
22 1.7 rillig #
23 1.7 rillig # Since the .if condition evaluated to false, this whole branch is not taken.
24 1.7 rillig .elsif 0
25 1.7 rillig . info XXX: This misspelling is not detected.
26 1.7 rillig . info This branch is not taken.
27 1.7 rillig # Even if the misspelling were detected, the branch would not be taken
28 1.7 rillig # since the condition of the '.elsif' evaluates to false as well.
29 1.7 rillig .endif
30 1.7 rillig
31 1.7 rillig
32 1.7 rillig # Misspelling '.elsif' below an .if branch that is not taken.
33 1.7 rillig .if 0
34 1.7 rillig . info This branch is not taken.
35 1.7 rillig # As of 2020-12-19, the misspelling is not recognized as a conditional
36 1.7 rillig # directive and is thus silently skipped. Since the .if condition evaluated
37 1.7 rillig # to false, this whole branch is not taken.
38 1.7 rillig .elsif 1
39 1.7 rillig . info XXX: This misspelling is not detected.
40 1.7 rillig # If the misspelling were detected, this branch would be taken.
41 1.7 rillig .endif
42 1.7 rillig
43 1.7 rillig
44 1.7 rillig # Misspelling '.elsif' below an .if branch that is taken.
45 1.7 rillig .if 1
46 1.7 rillig # This misspelling is in an active branch and is therefore detected.
47 1.7 rillig .elsif 0
48 1.7 rillig # The only thing that make detects here is a misspelled directive, make
49 1.7 rillig # doesn't recognize that it was meant to be a conditional directive.
50 1.7 rillig # Therefore the branch continues here, even though the '.elsif' condition
51 1.7 rillig # evaluates to false.
52 1.7 rillig . info This branch is taken.
53 1.7 rillig .endif
54 1.7 rillig
55 1.7 rillig
56 1.7 rillig # Misspelling '.elsif' below an .if branch that is taken.
57 1.7 rillig .if 1
58 1.7 rillig # As of 2020-12-19, the misspelling is in an active branch and is therefore
59 1.7 rillig # detected.
60 1.7 rillig .elsif 1
61 1.7 rillig # Since both conditions evaluate to true, this branch is taken no matter
62 1.7 rillig # whether make detects a misspelling or not.
63 1.7 rillig . info This branch is taken.
64 1.7 rillig .endif
65 1.7 rillig
66 1.7 rillig
67 1.7 rillig # Misspelling '.elsif' in a skipped branch below a branch that was taken.
68 1.3 rillig .if 1
69 1.7 rillig . info This branch is taken.
70 1.7 rillig .elif 0
71 1.7 rillig . info This branch is not taken.
72 1.7 rillig .elsif 1
73 1.7 rillig . info XXX: This misspelling is not detected.
74 1.3 rillig .endif
75 1.3 rillig
76 1.7 rillig
77 1.7 rillig # Misspelling '.elsif' in an .else branch that is not taken.
78 1.7 rillig .if 1
79 1.7 rillig .else
80 1.7 rillig . info This branch is not taken.
81 1.7 rillig .elsif 1
82 1.7 rillig . info XXX: This misspelling is not detected.
83 1.3 rillig .endif
84 1.3 rillig
85 1.7 rillig
86 1.7 rillig # Misspelling '.elsif' in an .else branch that is taken.
87 1.3 rillig .if 0
88 1.7 rillig .else
89 1.7 rillig .elsif 1
90 1.7 rillig . info This misspelling is detected.
91 1.7 rillig . info This branch is taken because of the .else.
92 1.3 rillig .endif
93 1.7 rillig
94 1.7 rillig
95 1.7 rillig # Misspellings for .elif in a .elif branch that is not taken.
96 1.3 rillig .if 0
97 1.7 rillig . info This branch is not taken.
98 1.7 rillig .elif 0 # ok
99 1.7 rillig . info This branch is not taken.
100 1.7 rillig .elsif 0
101 1.7 rillig . info XXX: This misspelling is not detected.
102 1.7 rillig . info This branch is not taken.
103 1.7 rillig .elseif 0
104 1.7 rillig . info XXX: This misspelling is not detected.
105 1.7 rillig . info This branch is not taken.
106 1.3 rillig .endif
107 1.3 rillig
108 1.7 rillig
109 1.7 rillig .info What happens on misspelling in a skipped branch?
110 1.3 rillig .if 0
111 1.3 rillig . info 0-then
112 1.3 rillig .elsif 1
113 1.7 rillig . info XXX: This misspelling is not detected.
114 1.3 rillig . info 1-elsif
115 1.3 rillig .elsif 2
116 1.7 rillig . info XXX: This misspelling is not detected.
117 1.3 rillig . info 2-elsif
118 1.3 rillig .else
119 1.3 rillig . info else
120 1.3 rillig .endif
121 1.3 rillig
122 1.7 rillig .info What happens on misspelling in a taken branch?
123 1.3 rillig .if 1
124 1.3 rillig . info 1-then
125 1.3 rillig .elsif 1
126 1.3 rillig . info 1-elsif
127 1.3 rillig .elsif 2
128 1.3 rillig . info 2-elsif
129 1.3 rillig .else
130 1.3 rillig . info else
131 1.3 rillig .endif
132 1.3 rillig
133 1.4 rillig # Expect: "if-less elif"
134 1.4 rillig .elif 0
135 1.4 rillig
136 1.4 rillig .if 1
137 1.4 rillig .else
138 1.7 rillig # Expect: "warning: extra elif"
139 1.4 rillig .elif
140 1.4 rillig .endif
141 1.4 rillig
142 1.1 rillig all:
143