re PR bootstrap/68346 (Bootstrap failure on i686-linux)
authorJason Merrill <jason@redhat.com>
Tue, 17 Nov 2015 18:16:35 +0000 (13:16 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 17 Nov 2015 18:16:35 +0000 (13:16 -0500)
PR bootstrap/68346

* c-common.c (warn_tautological_cmp): Fold before checking for
constants.

From-SVN: r230471

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/g++.dg/warn/Wtautological-compare2.C [new file with mode: 0644]

index 3151e343a1de0ca9d6bf28bac4601dd4f2c7e916..9ba2ea0ed4f2b85456654ed86fadc5df84ee799e 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-17  Jason Merrill  <jason@redhat.com>
+
+       PR bootstrap/68346
+       * c-common.c (warn_tautological_cmp): Fold before checking for
+       constants.
+
 2015-11-16  Marek Polacek  <polacek@redhat.com>
 
        PR c++/68362
index 06d857cc9706db16e5f89a7e86c577fcd84ec3f8..f50ca48f4f2cd4bb047cb9c7152d947e37ad9956 100644 (file)
@@ -1924,7 +1924,7 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs)
 
   /* 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))
+  if (CONSTANT_CLASS_P (fold (lhs)) || CONSTANT_CLASS_P (fold (rhs)))
     return;
 
   /* Don't warn for e.g.
diff --git a/gcc/testsuite/g++.dg/warn/Wtautological-compare2.C b/gcc/testsuite/g++.dg/warn/Wtautological-compare2.C
new file mode 100644 (file)
index 0000000..9d9060d
--- /dev/null
@@ -0,0 +1,11 @@
+// PR bootstrap/68346
+// { dg-options -Wtautological-compare }
+
+#define INVALID_REGNUM                 (~(unsigned int) 0)
+#define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
+
+int main()
+{
+  if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)
+    __builtin_abort();
+}