Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / elidestringvar.cxx
blob913bfbc2ae03eb1eafa7fa28572f7878af184f0f
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 "rtl/ustring.hxx"
14 template <sal_Unicode C> OUString f(sal_Unicode c, int n)
16 OUString s0(C);
17 OUString s1(c);
18 // expected-note-re@+1 {{literal '{{(rtl::)?}}OUString' variable defined here [loplugin:elidestringvar]}}
19 OUString s2('a');
20 // expected-note-re@+1 {{literal '{{(rtl::)?}}OUString' variable defined here [loplugin:elidestringvar]}}
21 OUString s3(u'a');
22 static constexpr OUStringLiteral s4lit(u"a");
23 // expected-note-re@+1 {{literal '{{(rtl::)?}}OUString' variable defined here [loplugin:elidestringvar]}}
24 OUString s4 = s4lit;
25 switch (n)
27 case 0:
28 return s0;
29 case 1:
30 return s1;
31 case 2:
32 // expected-error-re@+1 {{replace single use of literal '{{(rtl::)?}}OUString' variable with a literal [loplugin:elidestringvar]}}
33 return s2;
34 case 3:
35 // expected-error-re@+1 {{replace single use of literal '{{(rtl::)?}}OUString' variable with a literal [loplugin:elidestringvar]}}
36 return s3;
37 default:
38 // expected-error-re@+1 {{replace single use of literal '{{(rtl::)?}}OUString' variable with a literal [loplugin:elidestringvar]}}
39 return s4;
43 // Trigger clang-cl to actually parse f under MSVC template instantiation model:
44 template OUString f<'a'>(sal_Unicode, int);
46 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */