Skip to content

Commit 2255ebb

Browse files
author
H. Peter Anvin
committed
preproc: don't evaluate an %if condition if suppressed
When a line is suppressed there is no guarantee that it is syntactically valid, so treat it exactly like a dead %if branch. Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
1 parent 6b1636a commit 2255ebb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

asm/preproc.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,9 +4821,17 @@ static int do_directive(Token *tline, Token **output, bool suppressed)
48214821
break;
48224822

48234823
CASE_PP_IF:
4824-
if (istk->conds && !emitting(istk->conds->state))
4824+
if (suppressed || (istk->conds && !emitting(istk->conds->state))) {
4825+
/*
4826+
* Don't evaluate the actual condition inside of a dead
4827+
* expansion, because it is entirely valid for it to be
4828+
* syntactically broken at this point. There is no point,
4829+
* anyway: the output from all branches of this conditionals
4830+
* will be suppressed, and the only reason this is being
4831+
* processed at all is to look for nested conditionals.
4832+
*/
48254833
j = COND_NEVER;
4826-
else {
4834+
} else {
48274835
j = if_condition(tline->next, op, dname);
48284836
tline->next = NULL; /* it got freed */
48294837
}

0 commit comments

Comments
 (0)