This PR exposed a defect in my -Wtautological-compare warning: we don't want to warn when the expression comes from a macro expansion.
Bootstrapped/regtested on x86_64-linux, applying to trunk. 2015-07-27 Marek Polacek <pola...@redhat.com> PR bootstrap/67030 * c-common.c (warn_tautological_cmp): Don't warn for macro expansion. * c-c++-common/Wtautological-compare-2.c: New test. diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index 6a79b95..caa801e 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -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)) diff --git gcc/testsuite/c-c++-common/Wtautological-compare-2.c gcc/testsuite/c-c++-common/Wtautological-compare-2.c index e69de29..c8aecef 100644 --- gcc/testsuite/c-c++-common/Wtautological-compare-2.c +++ gcc/testsuite/c-c++-common/Wtautological-compare-2.c @@ -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); +} Marek