2017-07-05 08:32:57 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool foo(int);
|
|
|
|
|
2017-07-06 14:49:15 +02:00
|
|
|
enum class EFoo { Bar };
|
|
|
|
|
2017-07-05 08:32:57 +02:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int x = 1;
|
|
|
|
x = ((2)); // expected-error {{parentheses around parentheses [loplugin:unnecessaryparen]}}
|
|
|
|
|
2017-07-05 16:30:06 +02:00
|
|
|
if ((foo(1))) foo(2); // expected-error {{parentheses immediately inside if statement [loplugin:unnecessaryparen]}}
|
2017-07-07 08:42:54 +02:00
|
|
|
|
|
|
|
foo((1)); // expected-error {{parentheses immediately inside single-arg call [loplugin:unnecessaryparen]}}
|
2017-07-06 14:49:15 +02:00
|
|
|
|
|
|
|
int y = (x); // expected-error {{unnecessary parentheses around identifier [loplugin:unnecessaryparen]}}
|
|
|
|
(void)y;
|
|
|
|
|
|
|
|
EFoo foo = EFoo::Bar;
|
|
|
|
switch (foo) {
|
2017-09-05 08:29:58 +02:00
|
|
|
case (EFoo::Bar): break; // expected-error {{parentheses immediately inside case statement [loplugin:unnecessaryparen]}}
|
2017-07-06 14:49:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// lots of our code uses this style, which I'm loathe to bulk-fix as yet
|
|
|
|
int z = (y) ? 1 : 0;
|
|
|
|
(void)z;
|
2017-09-04 08:53:38 +02:00
|
|
|
|
|
|
|
int v1 = (static_cast<short>(1)) + 1; // expected-error {{unnecessary parentheses around cast [loplugin:unnecessaryparen]}}
|
|
|
|
(void)v1;
|
2017-07-05 08:32:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|