directive-elif.mk revision 1.8 1 1.8 rillig # $NetBSD: directive-elif.mk,v 1.8 2023/06/01 20:56:35 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.8 rillig # expect+1: Unknown directive "elsif"
48 1.7 rillig .elsif 0
49 1.7 rillig # The only thing that make detects here is a misspelled directive, make
50 1.7 rillig # doesn't recognize that it was meant to be a conditional directive.
51 1.7 rillig # Therefore the branch continues here, even though the '.elsif' condition
52 1.7 rillig # evaluates to false.
53 1.8 rillig # expect+1: This branch is taken.
54 1.7 rillig . info This branch is taken.
55 1.7 rillig .endif
56 1.7 rillig
57 1.7 rillig
58 1.7 rillig # Misspelling '.elsif' below an .if branch that is taken.
59 1.7 rillig .if 1
60 1.8 rillig # The misspelling is in an active branch and is therefore detected.
61 1.8 rillig # expect+1: Unknown directive "elsif"
62 1.7 rillig .elsif 1
63 1.7 rillig # Since both conditions evaluate to true, this branch is taken no matter
64 1.7 rillig # whether make detects a misspelling or not.
65 1.8 rillig # expect+1: This branch is taken.
66 1.7 rillig . info This branch is taken.
67 1.7 rillig .endif
68 1.7 rillig
69 1.7 rillig
70 1.7 rillig # Misspelling '.elsif' in a skipped branch below a branch that was taken.
71 1.3 rillig .if 1
72 1.8 rillig # expect+1: This branch is taken.
73 1.7 rillig . info This branch is taken.
74 1.7 rillig .elif 0
75 1.7 rillig . info This branch is not taken.
76 1.7 rillig .elsif 1
77 1.7 rillig . info XXX: This misspelling is not detected.
78 1.3 rillig .endif
79 1.3 rillig
80 1.7 rillig
81 1.7 rillig # Misspelling '.elsif' in an .else branch that is not taken.
82 1.7 rillig .if 1
83 1.7 rillig .else
84 1.7 rillig . info This branch is not taken.
85 1.7 rillig .elsif 1
86 1.7 rillig . info XXX: This misspelling is not detected.
87 1.3 rillig .endif
88 1.3 rillig
89 1.7 rillig
90 1.7 rillig # Misspelling '.elsif' in an .else branch that is taken.
91 1.3 rillig .if 0
92 1.7 rillig .else
93 1.8 rillig # expect+1: Unknown directive "elsif"
94 1.7 rillig .elsif 1
95 1.8 rillig # expect+1: This misspelling is detected.
96 1.7 rillig . info This misspelling is detected.
97 1.8 rillig # expect+1: This branch is taken because of the .else.
98 1.7 rillig . info This branch is taken because of the .else.
99 1.3 rillig .endif
100 1.7 rillig
101 1.7 rillig
102 1.7 rillig # Misspellings for .elif in a .elif branch that is not taken.
103 1.3 rillig .if 0
104 1.7 rillig . info This branch is not taken.
105 1.7 rillig .elif 0 # ok
106 1.7 rillig . info This branch is not taken.
107 1.7 rillig .elsif 0
108 1.7 rillig . info XXX: This misspelling is not detected.
109 1.7 rillig . info This branch is not taken.
110 1.7 rillig .elseif 0
111 1.7 rillig . info XXX: This misspelling is not detected.
112 1.7 rillig . info This branch is not taken.
113 1.3 rillig .endif
114 1.3 rillig
115 1.7 rillig
116 1.8 rillig # expect+1: What happens on misspelling in a skipped branch?
117 1.7 rillig .info What happens on misspelling in a skipped branch?
118 1.3 rillig .if 0
119 1.3 rillig . info 0-then
120 1.3 rillig .elsif 1
121 1.7 rillig . info XXX: This misspelling is not detected.
122 1.3 rillig . info 1-elsif
123 1.3 rillig .elsif 2
124 1.7 rillig . info XXX: This misspelling is not detected.
125 1.3 rillig . info 2-elsif
126 1.3 rillig .else
127 1.8 rillig # expect+1: else
128 1.3 rillig . info else
129 1.3 rillig .endif
130 1.3 rillig
131 1.8 rillig # expect+1: What happens on misspelling in a taken branch?
132 1.7 rillig .info What happens on misspelling in a taken branch?
133 1.3 rillig .if 1
134 1.8 rillig # expect+1: 1-then
135 1.3 rillig . info 1-then
136 1.8 rillig # expect+1: Unknown directive "elsif"
137 1.3 rillig .elsif 1
138 1.8 rillig # expect+1: 1-elsif
139 1.3 rillig . info 1-elsif
140 1.8 rillig # expect+1: Unknown directive "elsif"
141 1.3 rillig .elsif 2
142 1.8 rillig # expect+1: 2-elsif
143 1.3 rillig . info 2-elsif
144 1.3 rillig .else
145 1.3 rillig . info else
146 1.3 rillig .endif
147 1.3 rillig
148 1.8 rillig # expect+1: if-less elif
149 1.4 rillig .elif 0
150 1.4 rillig
151 1.4 rillig .if 1
152 1.4 rillig .else
153 1.8 rillig # expect+1: warning: extra elif
154 1.4 rillig .elif
155 1.4 rillig .endif
156 1.4 rillig
157 1.1 rillig all:
158