bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / test / staticconstfield.cxx
blobfd36a6452bfb97388b35892bc0f0429acf755c06
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 <rtl/ustring.hxx>
12 #include <rtl/string.hxx>
13 #include <vector>
15 class Class1
17 OUString const
18 m_field1; // expected-error {{const field can be static [loplugin:staticconstfield]}}
19 Class1()
20 : m_field1("xxxx")
21 // expected-note@-1 {{init here [loplugin:staticconstfield]}}
23 (void)m_field1;
27 class Class2
29 OString const
30 m_field2; // expected-error {{const field can be static [loplugin:staticconstfield]}}
31 Class2()
32 : m_field2("yyyy")
33 // expected-note@-1 {{init here [loplugin:staticconstfield]}}
35 (void)m_field2;
39 // no warning expected
40 class Class4
42 OUString m_field3;
43 Class4()
44 : m_field3("zzzz")
46 (void)m_field3;
50 class Class5
52 enum class Enum
54 ONE
56 float const
57 m_fielda1; // expected-error {{const field can be static [loplugin:staticconstfield]}}
58 int const m_fielda2; // expected-error {{const field can be static [loplugin:staticconstfield]}}
59 bool const
60 m_fielda3; // expected-error {{const field can be static [loplugin:staticconstfield]}}
61 Enum const
62 m_fielda4; // expected-error {{const field can be static [loplugin:staticconstfield]}}
63 Class5()
64 : m_fielda1(1.0)
65 // expected-note@-1 {{init here [loplugin:staticconstfield]}}
66 , m_fielda2(1)
67 // expected-note@-1 {{init here [loplugin:staticconstfield]}}
68 , m_fielda3(true)
69 // expected-note@-1 {{init here [loplugin:staticconstfield]}}
70 , m_fielda4(Enum::ONE)
71 // expected-note@-1 {{init here [loplugin:staticconstfield]}}
73 (void)m_fielda1;
74 (void)m_fielda2;
75 (void)m_fielda3;
76 (void)m_fielda4;
80 // no warning expected
81 class Class6
83 enum class Enum
85 ONE
87 float m_fieldb1;
88 int m_fieldb2;
89 bool m_fieldb3;
90 Enum m_fieldb4;
91 Class6()
92 : m_fieldb1(1.0)
93 , m_fieldb2(1)
94 , m_fieldb3(true)
95 , m_fieldb4(Enum::ONE)
97 (void)m_fieldb1;
98 (void)m_fieldb2;
99 (void)m_fieldb3;
100 (void)m_fieldb4;
104 // no warning expected, checking for assigning to const field from multiple constructors
105 class Class7
107 bool const m_field7;
108 Class7()
109 : m_field7(true)
111 (void)m_field7;
113 Class7(bool b)
114 : m_field7(b)
116 (void)m_field7;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */