diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 13ad6d29577..58fadf06771 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2677,7 +2677,7 @@ void CheckOther::checkDuplicateBranch() const std::string branch2 = tokElse->stringifyList(scope.bodyEnd->linkAt(2)); // check for duplicates - if (branch1 == branch2) { + if (branch1 == branch2 && branch1 != ";") { duplicateBranchError(scope.classDef, scope.bodyEnd->next(), ErrorPath{}); continue; } diff --git a/test/testother.cpp b/test/testother.cpp index bac5dfbdf7f..6b88e5b68b0 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -7304,6 +7304,15 @@ class TestOther : public TestFixture { " }\n" "}"); ASSERT_EQUALS("", errout_str()); + + check("void f(int i) {\n" + " if (1 == i) {\n" + " ;\n" + " } else {\n" + " ;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void duplicateBranch6() {