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('''