check-namespace: don't require comment after #else (#6513)
This commit is contained in:
@@ -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 ''
|
||||
|
||||
@@ -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('''
|
||||
|
||||
Reference in New Issue
Block a user