From b15f79a8f8de27c9d186ae1fbd0c86f194aed0ac Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 30 Nov 2017 07:17:53 +0100 Subject: loplugin:unnecessaryparen: signed numeric literals Change-Id: I75c8224452ca9c3711a2ccaca9ecf549fa59cb64 Reviewed-on: https://gerrit.libreoffice.org/45549 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/test/unnecessaryparen.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compilerplugins/clang/test') diff --git a/compilerplugins/clang/test/unnecessaryparen.cxx b/compilerplugins/clang/test/unnecessaryparen.cxx index 78e2096abf9e..b7117a126edb 100644 --- a/compilerplugins/clang/test/unnecessaryparen.cxx +++ b/compilerplugins/clang/test/unnecessaryparen.cxx @@ -82,6 +82,15 @@ int main() // Expecting just one error, not reported twice during TraverseInitListExpr: int a[] = {(x)}; // expected-error {{unnecessary parentheses around identifier [loplugin:unnecessaryparen]}} (void) a; + + (void) (+1); // expected-error {{unnecessary parentheses around signed numeric literal [loplugin:unnecessaryparen]}} + (void) (-1); // expected-error {{unnecessary parentheses around signed numeric literal [loplugin:unnecessaryparen]}} + + // For simplicity's sake, even warn about pathological cases that would require adding + // whitespace when removing the parentheses (as is also necessary in other cases anyway, like + // "throw(x);"); it is unlikely that there are any actual occurrences of code like "-(-1)" that + // would benefit from the parentheses readability-wise, compared to "- -1": + (void) -(-1); // expected-error {{unnecessary parentheses around signed numeric literal [loplugin:unnecessaryparen]}} }; struct S2 { -- cgit