1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
13 extern int bar(int = 0);
17 if (foo() == 1) { // expected-note {{if condition here [loplugin:flatten]}}
20 throw std::exception(); // expected-error {{unconditional throw in else branch, rather invert the condition, throw early, and flatten the normal case [loplugin:flatten]}}
26 throw std::exception(); // no warning expected
28 if (foo() == 1) { // expected-note {{if condition here [loplugin:flatten]}}
32 throw std::exception(); // expected-error {{unconditional throw in else branch, rather invert the condition, throw early, and flatten the normal case [loplugin:flatten]}}
38 throw std::exception(); // expected-error {{unconditional throw in then branch, just flatten the else [loplugin:flatten]}}
43 throw std::exception(); // no warning expected
49 throw std::exception(); // expected-error {{unconditional throw in then branch, just flatten the else [loplugin:flatten]}}
57 // no warning expected
59 throw std::exception();
69 // no warning expected
74 throw std::exception();
83 if (foo() == 3) { // expected-note {{if condition here [loplugin:flatten]}}
86 throw std::exception(); // expected-error {{unconditional throw in else branch, rather invert the condition, throw early, and flatten the normal case [loplugin:flatten]}}
90 throw std::exception(); // no warning expected
94 // no warning expected
96 throw std::exception();
98 throw std::exception();
103 // no warning expected
107 } else if (foo() == 2) {
111 throw std::exception();
118 // no warning expected
120 throw std::exception();
121 } else if (foo() == 2) {
122 throw std::exception();
124 throw std::exception();
131 throw std::exception(); // expected-error {{unconditional throw in then branch, just flatten the else [loplugin:flatten]}}
135 } else if (foo() == 2) {
143 if (foo() == 1) { // expected-error {{large if statement at end of function, rather invert the condition and exit early, and flatten the function [loplugin:flatten]}}
160 // no warning expected
174 // no warning expected
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */