I'm getting a bootstrap failure in stage 2 on arm-none-linux-gnueabihf due to the new warning: $SRC/gcc/cfgexpand.c: In function 'long long int expand_one_var(tree, bool, bool)': $SRC/gcc/defaults.h:1156:55: error: self-comparison always evaluates to false [-Werror=tautological-compare] #define SUPPORTS_STACK_ALIGNMENT (MAX_STACK_ALIGNMENT > STACK_BOUNDARY) Seems we need to be a bit smarter when it comes to macro expansions?
Could you please try whether this patch helps? diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 6a79b95..9fe9c5e 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1890,6 +1890,10 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs) if (TREE_CODE_CLASS (code) != tcc_comparison) return; + if (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))
(In reply to Marek Polacek from comment #1) > Could you please try whether this patch helps? > Trying it out now...
(In reply to ktkachov from comment #2) > (In reply to Marek Polacek from comment #1) > > Could you please try whether this patch helps? > > > > Trying it out now... Unfortunately still getting the error. One thing I missed out from the original error message is this note: error: self-comparison always evaluates to false [-Werror=tautological-compare] #define SUPPORTS_STACK_ALIGNMENT (MAX_STACK_ALIGNMENT > STACK_BOUNDARY) $SRC/gcc/cfgexpand.c:1268:7: note: in expansion of macro 'SUPPORTS_STACK_ALIGNMENT' if (SUPPORTS_STACK_ALIGNMENT ^ Don't know if that helps.
(In reply to ktkachov from comment #3) > Unfortunately still getting the error. Sorry about that. > One thing I missed out from the original error message is this note: > > error: self-comparison always evaluates to false > [-Werror=tautological-compare] > #define SUPPORTS_STACK_ALIGNMENT (MAX_STACK_ALIGNMENT > STACK_BOUNDARY) > > $SRC/gcc/cfgexpand.c:1268:7: note: in expansion of macro > 'SUPPORTS_STACK_ALIGNMENT' > if (SUPPORTS_STACK_ALIGNMENT > ^ > > Don't know if that helps. Actually, that helps. I bet the following works. Mind giving this one a spin? --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1890,6 +1890,11 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs) if (TREE_CODE_CLASS (code) != tcc_comparison) return; + 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))
Testcase: #define A a #define B A #define FOO (A > B) int main () { int a = 4; if (FOO) return 5; }
(In reply to Marek Polacek from comment #4) > (In reply to ktkachov from comment #3) > > Actually, that helps. I bet the following works. Mind giving this one a > spin? Yes, that seems to work. Bootstrap proceeds from that point i.e. cfgexpand.c compiles. I have to go offline for the day, so I'll have the full bootstrap result tomorrow but from what I can see this is an obvious fix (to my limited C frontend experience) and it would be nice to have it in ASAP to fix arm bootstrap. Thanks for the quick response. > > --- a/gcc/c-family/c-common.c > +++ b/gcc/c-family/c-common.c > @@ -1890,6 +1890,11 @@ warn_tautological_cmp (location_t loc, enum tree_code > code, tree lhs, tree rhs) > if (TREE_CODE_CLASS (code) != tcc_comparison) > return; > > + 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))
(In reply to ktkachov from comment #6) > Yes, that seems to work. Bootstrap proceeds from that point i.e. cfgexpand.c > compiles. > > I have to go offline for the day, so I'll have the full bootstrap result > tomorrow but from what I can see this is an obvious fix (to my limited C > frontend experience) and it would be nice to have it in ASAP to fix arm > bootstrap. Thanks, glad to hear that. I'll commit the patch after doing some testing on x86_64 (give me ~2 hours).
FYI, I'm running into this bootstrap failure on x86_64 (r226251): ... src/gcc/ipa-devirt.c: In function ‘bool types_same_for_odr(const_tree, const_tree, bool)’: src/gcc/ipa-devirt.c:553:8: error: self-comparison always evaluates to false [-Werror=tautological-compare] != (TYPE_BINFO (type1) == NULL_TREE)) ...
(In reply to vries from comment #8) > FYI, I'm running into this bootstrap failure on x86_64 (r226251): Weird I don't see this myself. > ... > src/gcc/ipa-devirt.c: In function ‘bool types_same_for_odr(const_tree, > const_tree, bool)’: > src/gcc/ipa-devirt.c:553:8: error: self-comparison always evaluates to false > [-Werror=tautological-compare] > != (TYPE_BINFO (type1) == NULL_TREE)) > ... 551 if (TREE_CODE (type1) == RECORD_TYPE 552 && (TYPE_BINFO (type1) == NULL_TREE) 553 != (TYPE_BINFO (type1) == NULL_TREE)) Ok, that's a clear typo; something that this warning is designed to detect. I'm fixing this separately. Thanks for reporting.
Author: mpolacek Date: Mon Jul 27 19:09:27 2015 New Revision: 226264 URL: https://gcc.gnu.org/viewcvs?rev=226264&root=gcc&view=rev Log: PR bootstrap/67030 * c-common.c (warn_tautological_cmp): Don't warn for macro expansion. * c-c++-common/Wtautological-compare-2.c: New test. Added: trunk/gcc/testsuite/c-c++-common/Wtautological-compare-2.c Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-common.c trunk/gcc/testsuite/ChangeLog
Fixed (fingers crossed).
Still... ../../gcc/ipa-devirt.c: In function ‘bool types_same_for_odr(const_tree, const_tree, bool ’: ../../gcc/ipa-devirt.c:553:8: error: self-comparison always evaluates to false [-Werror=tautological-compare] != (TYPE_BINFO (type1) == NULL_TREE)) ^
That is fixed as well now.
(In reply to Marek Polacek from comment #13) > That is fixed as well now. Yep. Thanks.
Yeah, that problem is fixed. Now bootstrap fails due to: gcc/vec.h:307:3: error: attempt to free a non-heap object 'intersecting' [-Werror=free-nonheap-object] ::free (v); ^ But that must be a different problem. Will analyze and file a separate PR...
Yeah, that doesn't look related to this warning at all. Thanks for checking.
(In reply to Marek Polacek from comment #16) > Yeah, that doesn't look related to this warning at all. Thanks for checking. Yeah, turns out that was due to a private patch of mine. Clean trunk bootstraps ok. Sorry for the noise.