Version 24.2.2.2, tag libreoffice-24.2.2.2
[LibreOffice.git] / compilerplugins / clang / test / stringconcatauto.cxx
blobdde4211eaee4eb5620864608a05b62fab396fc8d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * Based on LLVM/Clang.
7 * This file is distributed under the University of Illinois Open Source
8 * License. See LICENSE.TXT for details.
12 #include <rtl/ustring.hxx>
14 void foo()
16 auto str1 = "str1" + OUString::number(10);
17 // expected-error-re@-1 {{creating a variable of type {{.+}} will make it reference temporaries}}
18 // expected-note@-2 {{use O(U)String instead}}
19 OUString str2 = "str2" + OUString::number(20) + "ing";
20 const auto& str3 = "str3" + OUString::number(30);
21 // expected-error-re@-1 {{creating a variable of type {{.+}} will make it reference temporaries}}
22 // expected-note@-2 {{use O(U)String instead}}
23 const auto str4 = "str4" + OString::number(40);
24 // expected-error-re@-1 {{creating a variable of type {{.+}} will make it reference temporaries}}
25 // expected-note@-2 {{use O(U)String instead}}
26 auto str5 = OUString::number(50);
27 auto str6 = OUString::number(50).toAsciiUpperCase();
28 (void)str1;
29 (void)str2;
30 (void)str3;
31 (void)str4;
32 (void)str5;
33 (void)str6;
36 struct A
38 auto bar()
39 // expected-error-re@-1 {{returning a variable of type {{.+}} will make it reference temporaries}}
40 // expected-note@-2 {{use O(U)String instead}}
42 return "bar" + OString::number(110);
44 auto baz() { return OString::number(120); }
45 auto baz2() { return OString::number(120).toAsciiUpperCase(); }
48 template <typename T> void fun(const T& par)
49 // parameters are without warnings
51 const T& var = par;
52 // expected-error-re@-1 {{creating a variable of type 'const rtl::StringConcat<{{.*}}> &' will make it reference temporaries}}
53 // expected-note@-2 {{use O(U)String instead}}
54 (void)var;
57 void testfun() { fun("fun" + OUString::number(200)); }
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */