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