Skip to content

Commit b9513d3

Browse files
authored
Fix #14487: FP duplicateBranch with empty macro (#8481)
My reasoning here is that a single semicolon most likely is a result of an empty macro expansion. I can't think of a case where one would put a single semicolon where it would make sense to warn.
1 parent a3faaa7 commit b9513d3

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ void CheckOther::checkDuplicateBranch()
26922692
const std::string branch2 = tokElse->stringifyList(scope.bodyEnd->linkAt(2));
26932693

26942694
// check for duplicates
2695-
if (branch1 == branch2) {
2695+
if (branch1 == branch2 && branch1 != ";") {
26962696
duplicateBranchError(scope.classDef, scope.bodyEnd->next(), ErrorPath{});
26972697
continue;
26982698
}

test/testother.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7316,6 +7316,15 @@ class TestOther : public TestFixture {
73167316
" }\n"
73177317
"}");
73187318
ASSERT_EQUALS("", errout_str());
7319+
7320+
check("void f(int i) {\n"
7321+
" if (1 == i) {\n"
7322+
" ;\n"
7323+
" } else {\n"
7324+
" ;\n"
7325+
" }\n"
7326+
"}\n");
7327+
ASSERT_EQUALS("", errout_str());
73197328
}
73207329

73217330
void duplicateBranch6() {

0 commit comments

Comments
 (0)