bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / test / staticvar.cxx
blob639e6cce46d34e8b4432f982c963c32136a4bf57
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 <config_clang.h>
11 #include <sal/config.h>
12 #include <rtl/ustring.hxx>
14 struct S1
16 int x, y;
19 S1 const& f1(int a)
21 static S1 s1[]{
22 // expected-error@-1 {{var should be static const, or whitelisted [loplugin:staticvar]}}
23 { 1, 1 }
25 // no warning expected
26 const S1 s2[]{ { a, 1 } };
27 (void)s2;
28 return s1[0];
31 struct S2
33 OUString x;
36 S2 const& f2()
38 static S2 const s1[]{
39 // expected-error@-1 {{static const var requires runtime initialization? [loplugin:staticvar]}}
40 { "xxx" }
42 return s1[0];
45 // no warning expected
46 S2 const& f3()
48 static S2 s1[]{ { "xxx" } };
49 return s1[0];
52 // no warning expected
53 struct S4
55 OUStringLiteral const cName;
56 bool const bCanBeVisible;
58 S4 const& f4()
60 static const S4 s1[] = {
61 { OUStringLiteral("/DocColor"), false },
63 return s1[0];
66 struct S5
68 bool const bCanBeVisible;
70 void f5(bool b)
72 const S5 s1[] = {
73 { b },
75 (void)s1;
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */