bump product version to 6.4.0.3
[LibreOffice.git] / compilerplugins / clang / test / stringconcatliterals.cxx
blobe2d5a8ce20e3365df3d0a24363291919bc334f7f
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 #define FOO "foo"
19 void f(std::ostream& s1)
21 static char const foo[] = "foo";
22 s1 << "foo"
23 << "foo";
24 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
25 s1 << "foo" << FOO;
26 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
27 s1 << "foo" << foo;
28 s1 << "foo" << OString("foo");
29 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
30 s1 << "foo" << OString(FOO);
31 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
32 s1 << "foo" << OString(foo);
33 s1 << "foo" << OUString("foo");
34 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
35 s1 << "foo" << OUString(FOO);
36 // expected-error@-1 {{replace '<<' between string literals with juxtaposition}}
37 s1 << "foo" << OUString(foo);
38 s1 << "foo" << OUStringLiteral("foo"); //TODO: warn too, OUStringLiteral wrapped in OUString
39 s1 << "foo" << OUStringLiteral(FOO); //TODO: warn too, OUStringLiteral wrapped in OUString
40 s1 << "foo" << OUStringLiteral(foo);
41 OString s2;
42 s2 = "foo" + OString("foo");
43 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
44 s2 = "foo" + OString(FOO);
45 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
46 s2 = "foo" + OString(foo);
47 s2 = "foo" + OStringLiteral("foo");
48 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
49 s2 = "foo" + OStringLiteral(FOO);
50 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
51 s2 = "foo" + OStringLiteral(foo);
52 OUString s3;
53 s3 = "foo" + OUString("foo");
54 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
55 s3 = "foo" + OUString(FOO);
56 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
57 s3 = "foo" + OUString(foo);
58 s3 = "foo" + OUStringLiteral("foo");
59 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
60 s3 = "foo" + OUStringLiteral(FOO);
61 // expected-error@-1 {{replace '+' between string literals with juxtaposition}}
62 s3 = "foo" + OUStringLiteral(foo);
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */