aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-08-25 12:48:34 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-08-25 12:48:34 +0000
commitebef225f4d824e45982955fe2a3cceb4f8cbae0e (patch)
tree64f9fab13affc9a9f00a3ad4510b0ea04da7f713 /gcc/testsuite
parent30df8b9f1e45879851eca44923eb77b0099fa24e (diff)
downloadgcc-ebef225f4d824e45982955fe2a3cceb4f8cbae0e.zip
gcc-ebef225f4d824e45982955fe2a3cceb4f8cbae0e.tar.gz
gcc-ebef225f4d824e45982955fe2a3cceb4f8cbae0e.tar.bz2
c-common.c (warn_logical_not_parentheses): Print fixit hints.
* c-common.c (warn_logical_not_parentheses): Print fixit hints. * c-common.h (warn_logical_not_parentheses): Update declaration. * c-typeck.c (parser_build_binary_op): Pass LHS to warn_logical_not_parentheses. * parser.c (cp_parser_binary_expression): Pass LHS to warn_logical_not_parentheses. * c-c++-common/Wlogical-not-parentheses-2.c: New test. Co-Authored-By: David Malcolm <dmalcolm@redhat.com> From-SVN: r239756
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/Wlogical-not-parentheses-2.c20
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4dddd8..caeaa7e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2016-08-25 Marek Polacek <polacek@redhat.com>
+ * c-c++-common/Wlogical-not-parentheses-2.c: New test.
+
+2016-08-25 Marek Polacek <polacek@redhat.com>
+
PR c/77323
* gcc.dg/pr77323.c: New test.
diff --git a/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-2.c b/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-2.c
new file mode 100644
index 0000000..ba8dce8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-2.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-not-parentheses -fdiagnostics-show-caret" } */
+
+ /* Test fixit hints. */
+
+int
+foo (int aaa, int bbb)
+{
+ int r = 0;
+ r += (!aaa) == bbb;
+ r += !aaa == bbb; /* { dg-warning "logical not is only applied" } */
+/* { dg-begin-multiline-output "" }
+ r += !aaa == bbb;
+ ^~
+ r += !aaa == bbb;
+ ^~~~
+ ( )
+ { dg-end-multiline-output "" } */
+ return r;
+}