diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index a81a57f339a41d41d81a3c8eaf673b024a110bbc..744465f398018e69e1d76f8064f120369bc1ed34 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -160,7 +160,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
             if (tryExpression(true))
                 break;
             switch (kind) {
-            case T_RBRACE:
+            case T_RBRACE:      leave(true); continue;
             case T_SEMICOLON:   leave(true); break;
             case T_EQUAL:       enter(initializer); break;
             case T_LBRACE:      enter(defun_open); break;
@@ -251,7 +251,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
             if (tryStatement())
                 break;
             switch (kind) {
-            case T_RBRACE:      leave(); continue; // always nested in declaration_start
+            case T_RBRACE:      leave(); leave(); break; // always nested in declaration_start
             } break;
 
         case switch_statement:
diff --git a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
index bebe2383c29b0ec342e4ef28d4a3d2343bfe11a1..155a28810a4eaf6b972315145d335b31e498f7fe 100644
--- a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
+++ b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
@@ -49,6 +49,7 @@ private Q_SLOTS:
     void nestedInitializer();
     void forStatement();
     void templateSingleline();
+    void macrosNoSemicolon2();
 };
 
 struct Line {
@@ -952,6 +953,19 @@ void tst_CodeFormatter::templateSingleline()
     checkIndent(data);
 }
 
+void tst_CodeFormatter::macrosNoSemicolon2()
+{
+    QList<Line> data;
+    data
+         << Line("FOO(ABC)")
+         << Line("{")
+         << Line("    BAR(FOO)")
+         << Line("}")
+         << Line("int i;")
+         ;
+    checkIndent(data);
+}
+
 QTEST_APPLESS_MAIN(tst_CodeFormatter)
 #include "tst_codeformatter.moc"