Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / indentation.cxx
blob1c57c6ceea98976530e4d13386884374e686162e
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 int foo();
11 int foo2(int);
13 #define SOME_MACRO(x) foo2(x)
15 void top1(int x) {
17 foo(); // expected-note {{measured against this one [loplugin:indentation]}}
18 foo(); // expected-error {{statement mis-aligned compared to neighbours [loplugin:indentation]}}
21 foo(); // expected-note {{measured against this one [loplugin:indentation]}}
22 SOME_MACRO(1); // expected-error {{statement mis-aligned compared to neighbours SOME_MACRO [loplugin:indentation]}}
24 // no warning expected
26 foo(); foo();
28 // no warning expected
29 /*xxx*/ foo();
32 // disable this for now, ends up touching some very large switch statements in sw/ and sc/
33 switch (x)
35 case 1: foo(); break; // 1expected-note {{measured against this one [loplugin:indentation]}}
36 case 2: foo(); break; // 1expected-error {{statement mis-aligned compared to neighbours [loplugin:indentation]}}
40 if (x)
41 foo(); // expected-error {{if body should be indented [loplugin:indentation]}}
43 if (x)
45 foo();
48 if (x)
49 { // expected-note {{start brace here [loplugin:indentation]}}
50 foo();
51 } // expected-error {{start and end brace not aligned [loplugin:indentation]}}
53 if (x) // expected-note {{statement beginning here [loplugin:indentation]}}
54 { // expected-error {{start brace not aligned with beginning of parent statement [loplugin:indentation]}}
55 foo();
58 if (x)
60 else
61 foo(); // expected-error {{else body should be indented [loplugin:indentation]}}
63 if (x)
65 else
67 foo();
70 if (x)
72 else // expected-error {{if and else not aligned [loplugin:indentation]}}
73 foo();
75 if (x)
77 } else
79 foo();
82 #if 0
83 if (x)
84 foo();
85 else
86 #endif
87 foo();
90 void attr() {
91 [[maybe_unused]] int i = foo();
92 foo();
95 void attr_bad() {
96 [[maybe_unused]] int i = foo(); // expected-note {{measured against this one [loplugin:indentation]}}
97 foo(); // expected-error {{statement mis-aligned compared to neighbours [loplugin:indentation]}}
100 void xxx();
101 void test5(bool x)
103 if (x)
105 xxx(); // expected-error {{body inside brace not indented [loplugin:indentation]}}
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */