From e407e73e241c1e1eb1375387986578fa1c287168 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 19 Sep 2022 17:45:44 +0200 Subject: [PATCH] check-namespace: don't require comment after #else (#6513) --- tests/scripted/check-namespace | 4 +++- tests/scripted/verify | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/scripted/check-namespace b/tests/scripted/check-namespace index 8c1b405ad..5f71505b2 100755 --- a/tests/scripted/check-namespace +++ b/tests/scripted/check-namespace @@ -164,8 +164,10 @@ for cur_file in files: if not expectations: error(cur_file, m, f'Unexpected {statement}') break - # Don't pop the expectation for an #else tag, we are still waiting for the #endif if statement.startswith('#el') and expectations[-1].statement == '#endif': + # After an #else or #elif the comment is no longer mandatory, since it's hard to define + expectations[-1] = Expectation(IF_MACRO, '#endif', '') + # Don't pop the expectations, we are still waiting for the #endif continue exp = expectations.pop() name = m.group('macro_name') or m.group('namespace_end') or '' diff --git a/tests/scripted/verify b/tests/scripted/verify index 20a26a303..4072aaf9f 100755 --- a/tests/scripted/verify +++ b/tests/scripted/verify @@ -232,6 +232,17 @@ with tempfile.TemporaryDirectory() as tmpdir: } // namespace smml #endif // ABC_H ''') + create_file('09_NoEndifAfterElseIsOk.cpp', ''' + #ifdef XYZ + namespace lmms { + \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n + } + #else + namespace lmms { + \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n + } + #endif + ''') test.run() test.expect('8 errors') test.expect('''