Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / stringconcatliterals.cxx
blob8b390f28fbbbe0a154ad9dfeec910e1a032837d8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
12 #include <ostream>
14 #include <rtl/string.hxx>
15 #include <rtl/ustring.hxx>
17 #pragma clang diagnostic ignored "-Wunknown-warning-option" // for Clang < 13
18 #pragma clang diagnostic ignored "-Wunused-but-set-variable"
20 #define FOO "foo"
21 #define FOOu u"foo"
23 void f(std::ostream& s1)
25 static constexpr char foo[] = "foo";
26 static constexpr char16_t foou[] = u"foo";
27 s1 << "foo"
28 << "foo";
29 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
30 s1 << "foo" << FOO;
31 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
32 s1 << "foo" << foo;
33 s1 << "foo" << OString("foo");
34 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
35 s1 << "foo" << OString(FOO);
36 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
37 s1 << "foo" << OString(foo);
38 s1 << "foo" << OUString("foo");
39 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
40 s1 << "foo" << OUString(FOO);
41 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
42 s1 << "foo" << OUString(foo);
43 OString s2;
44 s2 = "foo" + OString("foo");
45 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
46 s2 = "foo" + OString(FOO);
47 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
48 s2 = "foo" + OString(foo);
49 s2 = "foo" + OStringLiteral("foo");
50 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
51 s2 = "foo" + OStringLiteral(FOO);
52 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
53 s2 = "foo" + OStringLiteral(foo);
54 OUString s3;
55 s3 = "foo" + OUString("foo");
56 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
57 s3 = "foo" + OUString(FOO);
58 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
59 s3 = "foo" + OUString(foo);
60 s3 = "foo" + OUStringLiteral(u"foo");
61 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
62 s3 = "foo" + OUStringLiteral(FOOu);
63 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
64 s3 = "foo" + OUStringLiteral(foou);
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */