Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / compilerplugins / clang / test / constparams.cxx
blob9390ce2dec1787b52027d4cb91b79eb9465bdcaa
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 <string>
12 struct Class1
14 int const * m_f1;
15 Class1(int * f1) : m_f1(f1) {} // expected-error {{this parameter can be const [loplugin:constparams]}}
18 struct Class2
20 int * m_f2;
21 Class2(int * f2) : m_f2(f2) {}
23 struct Class3
25 int * m_f2;
26 Class3(void * f2) : m_f2(static_cast<int*>(f2)) {}
29 int const * f1(int *); // expected-note {{canonical parameter declaration here [loplugin:constparams]}}
30 int const * f2(int *);
31 int const * f3(int *);
32 void g() {
33 int const * (*p1)(int *);
34 int n = 0;
35 f1(&n);
36 p1 = f2;
37 typedef void (*P2)();
38 P2 p2;
39 p2 = (P2) (f3);
41 int const * f1(int * p) { // expected-error {{this parameter can be const [loplugin:constparams]}}
42 return p;
44 void f4(std::string * p) {
45 *p = std::string("xxx");
48 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */