diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index c2ac2fb88d8a6b0a25a2cd0bb6b0fc7e4ec4fc5d..9ee2fa8815c46f63c9a27a8bf93d7f9204c1afae 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -564,6 +564,13 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
         case cpp_macro_cont:
             break;
 
+        case string_open:
+            if (!m_currentToken.isStringLiteral()) {
+                leave();
+                continue;
+            }
+            break;
+
         default:
             qWarning() << "Unhandled state" << m_currentState.top().type;
             break;
@@ -819,6 +826,9 @@ bool CodeFormatter::tryExpression(bool alsoExpression)
         break;
     }
 
+    if (m_currentToken.isStringLiteral())
+        newState = string_open;
+
     if (newState != -1) {
         if (alsoExpression)
             enter(expression);
@@ -1425,6 +1435,11 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
     case cpp_macro_cont:
         *indentDepth = m_tabSettings.m_indentSize;
         break;
+
+    case string_open:
+        *indentDepth = tokenPosition;
+        *paddingDepth = 0;
+        break;
     }
 
     // ensure padding and indent are >= 0
diff --git a/src/plugins/cpptools/cppcodeformatter.h b/src/plugins/cpptools/cppcodeformatter.h
index a19e688e58dfd8b8eee32762cb8618dfd58e48a2..c36a4f0df59971eadc4cd0797e94e5c0a2b37f27 100644
--- a/src/plugins/cpptools/cppcodeformatter.h
+++ b/src/plugins/cpptools/cppcodeformatter.h
@@ -180,7 +180,8 @@ public: // must be public to make Q_GADGET introspection work
         lambda_statement_expected,
         lambda_instroducer,              // when '=', '&' or ',' occurred within '[]'
         lambda_declarator,               // just after ']' when previous state is lambda_introducer
-        lambda_statement                 // just after '{' when previous state is lambda_declarator or lambda_declarator_or_expression
+        lambda_statement,                // just after '{' when previous state is lambda_declarator or lambda_declarator_or_expression
+        string_open
 
     };
     Q_ENUMS(StateType)
diff --git a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
index fadfccfdff8ea318880c0e794c62a3b8fc9979ed..891d26d69696e0b6736aaa068906214fe55cd54e 100644
--- a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
+++ b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
@@ -128,6 +128,7 @@ private Q_SLOTS:
     void attributeInAccessSpecifier();
     void braceReturn();
     void staticVarDeclWithTypeDecl();
+    void strings();
 };
 
 struct Line {
@@ -2154,6 +2155,23 @@ void tst_CodeFormatter::staticVarDeclWithTypeDecl()
     checkIndent(data);
 }
 
+void tst_CodeFormatter::strings()
+{
+    QList<Line> data;
+    data << Line("char *a = \"foo\"")
+         << Line("          \"bar\" \"why\"")
+         << Line("          \"baz\";")
+         << Line("void foo()")
+         << Line("{")
+         << Line("    func(1, 2, \"foo\"")
+         << Line("               \"bar\"")
+         << Line("               \"baz\", 4,")
+         << Line("    ~    5, 6);")
+         << Line("}")
+            ;
+    checkIndent(data);
+}
+
 QTEST_MAIN(tst_CodeFormatter)
 
 #include "tst_codeformatter.moc"