re PR bootstrap/67030 (ARM bootstrap failure due to [-Werror=tautological-compare])
authorMarek Polacek <polacek@redhat.com>
Mon, 27 Jul 2015 19:09:27 +0000 (19:09 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 27 Jul 2015 19:09:27 +0000 (19:09 +0000)
PR bootstrap/67030
* c-common.c (warn_tautological_cmp): Don't warn for macro expansion.

* c-c++-common/Wtautological-compare-2.c: New test.

From-SVN: r226264

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wtautological-compare-2.c [new file with mode: 0644]

index 4d2ed59..06853ea 100644 (file)
@@ -1,5 +1,10 @@
 2015-07-27  Marek Polacek  <polacek@redhat.com>
 
+       PR bootstrap/67030
+       * c-common.c (warn_tautological_cmp): Don't warn for macro expansion.
+
+2015-07-27  Marek Polacek  <polacek@redhat.com>
+
        PR c++/66555
        PR c/54979
        * c-common.c (find_array_ref_with_const_idx_r): New function.
index 6a79b95..caa801e 100644 (file)
@@ -1890,6 +1890,12 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs)
   if (TREE_CODE_CLASS (code) != tcc_comparison)
     return;
 
+  /* Don't warn for various macro expansions.  */
+  if (from_macro_expansion_at (loc)
+      || from_macro_expansion_at (EXPR_LOCATION (lhs))
+      || from_macro_expansion_at (EXPR_LOCATION (rhs)))
+    return;
+
   /* We do not warn for constants because they are typical of macro
      expansions that test for features, sizeof, and similar.  */
   if (CONSTANT_CLASS_P (lhs) || CONSTANT_CLASS_P (rhs))
index 3e409dd..b769807 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-27  Marek Polacek  <polacek@redhat.com>
+
+       PR bootstrap/67030
+       * c-c++-common/Wtautological-compare-2.c: New test.
+
 2015-07-27  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/66232
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-2.c b/gcc/testsuite/c-c++-common/Wtautological-compare-2.c
new file mode 100644 (file)
index 0000000..c8aecef
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR bootstrap/67030 */
+/* { dg-do compile } */
+/* { dg-options "-Wtautological-compare" } */
+
+extern int foo (void);
+
+#define A a
+#define B A
+#define FOO (A > B)
+
+void
+fn1 (int a)
+{
+  if (FOO);
+}