Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / compilerplugins / clang / test / salcall.cxx
blobe424432c40360b6950f9b733004e825cc9bf3259
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/types.h>
12 #define VOID void
14 class Class1
16 SAL_CALL Class1() {} // expected-error {{SAL_CALL unnecessary here [loplugin:salcall]}}
17 SAL_CALL ~Class1() {} // expected-error {{SAL_CALL unnecessary here [loplugin:salcall]}}
18 SAL_CALL operator int() // expected-error {{SAL_CALL unnecessary here [loplugin:salcall]}}
20 return 0;
23 void SAL_CALL method1(); // expected-error {{SAL_CALL unnecessary here [loplugin:salcall]}}
24 VOID method2() {}
25 // no SAL_CALL for above method2, even though "SAL_CALL" appears between definition of VOID and
26 // the declaration's name, "method2"
28 void SAL_CALL Class1::method1()
29 { // expected-error@-1 {{SAL_CALL unnecessary here [loplugin:salcall]}}
32 class Class2
34 void method1(); // expected-note {{SAL_CALL inconsistency [loplugin:salcall]}}
36 void SAL_CALL Class2::method1() {} // expected-error {{SAL_CALL inconsistency [loplugin:salcall]}}
38 // comment this out because it seems to generate a warning in some internal buffer of clang that I can't annotate
39 #if 0
40 // no warning, this appears to be legal
41 class Class3
43 void SAL_CALL method1(); // expected-error {{SAL_CALL unnecessary here [loplugin:salcall]}}
45 void Class3::method1() {}
46 #endif
48 // no warning, normal case for reference
49 class Class4
51 void method1();
53 void Class4::method1() {}
55 class Class5_1
57 virtual void method1(); // expected-note {{SAL_CALL inconsistency [loplugin:salcall]}}
58 virtual ~Class5_1();
60 class Class5_2
62 virtual void SAL_CALL method1();
63 virtual ~Class5_2();
65 class Class5_3 : public Class5_1, public Class5_2
67 virtual void SAL_CALL
68 method1() override; // expected-error {{SAL_CALL inconsistency [loplugin:salcall]}}
69 virtual ~Class5_3();
72 class Class6_1
74 virtual void SAL_CALL method1();
75 virtual ~Class6_1();
77 class Class6_2
79 virtual void SAL_CALL method1();
80 virtual ~Class6_2();
82 class Class6_3 : public Class6_1, public Class6_2
84 virtual void SAL_CALL method1() override;
85 virtual ~Class6_3();
88 class Class7_1
90 virtual void method1();
91 virtual ~Class7_1();
93 class Class7_2
95 virtual void method1();
96 virtual ~Class7_2();
98 class Class7_3 : public Class7_1, public Class7_2
100 virtual void method1() override;
101 virtual ~Class7_3();
104 class Class8_1
106 virtual void method2();
107 virtual ~Class8_1();
109 class Class8_2
111 virtual void SAL_CALL method2(); // expected-note {{SAL_CALL inconsistency [loplugin:salcall]}}
112 virtual ~Class8_2();
114 class Class8_3 : public Class8_1, public Class8_2
116 virtual void method2() override; // expected-error {{SAL_CALL inconsistency [loplugin:salcall]}}
117 virtual ~Class8_3();
120 #define M1(m) VOID m
121 class Class9
123 Class9(); // expected-note {{SAL_CALL inconsistency [loplugin:salcall]}}
124 M1(method1)(); // expected-note {{SAL_CALL inconsistency [loplugin:salcall]}}
125 void method2(); // expected-note {{SAL_CALL inconsistency [loplugin:salcall]}}
127 #define MC(num) \
128 Class##num::Class##num() {}
129 SAL_CALL MC(9) // expected-error {{SAL_CALL inconsistency [loplugin:salcall]}}
130 ; // to appease clang-format
131 void SAL_CALL Class9::method1() // expected-error {{SAL_CALL inconsistency [loplugin:salcall]}}
134 #define M2(T) T SAL_CALL
135 M2(void) Class9::method2() {} // expected-error {{SAL_CALL inconsistency [loplugin:salcall]}}
137 #if 0 // see TODO in SalCall::isSalCallFunction
138 class Class10
140 void method1();
142 #define M3(T, SAL_CALL) T SAL_CALL::
143 M3(void, Class10) method1() {} // false "SAL_CALL inconsistency"
144 #endif
146 #if 0 //TODO
147 template<typename> struct S {
148 virtual ~S();
149 virtual void f();
151 template<typename T> S<T>::~S() {}
152 template<typename T> void S<T>::f() {}
153 struct S2: S<int> {
154 ~S2();
155 void f() {}
157 int main() {
158 S2 s2;
159 s2->f();
161 #endif
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */