Skip to content

Commit 123ee30

Browse files
committed
Fix nested #if <ndef> condition
1 parent a04acb2 commit 123ee30

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

tests/functional/prepro94.bi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
#ifdef MACRO
4+
# ifndef ANOTHER_MACRO
5+
# error This should not happen
6+
# endif
7+
#else
8+
OK
9+
#endif

tests/functional/prepro94.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#line 1 "prepro94.bi"
2+
#line 8 "prepro94.bi"
3+
OK
4+
#line 10 "prepro94.bi"

zxbpp/zxbpp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ def p_ifn_header(p):
543543
global ENABLED
544544

545545
IFDEFS.append((ENABLED, p.lineno(2)))
546-
ENABLED = not ID_TABLE.defined(p[2])
546+
if ENABLED:
547+
ENABLED = not ID_TABLE.defined(p[2])
547548

548549

549550
def p_if_expr_header(p):

0 commit comments

Comments
 (0)