From 4d6b421a33b02b1e754784e00e09245eab35aba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 23 Apr 2026 09:20:39 +0200 Subject: [PATCH 1/2] add test --- test/testother.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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() { From 188c7c06c82003a6c2a717d97198ee231790ff65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 23 Apr 2026 09:17:07 +0200 Subject: [PATCH 2/2] fix --- lib/checkother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }