diff options
author | Jason Merrill <jason@redhat.com> | 2019-04-03 16:12:00 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-04-03 16:12:00 -0400 |
commit | 7a506c3c63873916f318b6152367f81de1b3f57f (patch) | |
tree | 06de43d6d304f06c9707c4b3abdd09cab3225c08 /gcc | |
parent | b8836dbec1a36eb3a00c789a4ed1e64ba28ee6fe (diff) | |
download | gcc-7a506c3c63873916f318b6152367f81de1b3f57f.zip gcc-7a506c3c63873916f318b6152367f81de1b3f57f.tar.gz gcc-7a506c3c63873916f318b6152367f81de1b3f57f.tar.bz2 |
PR c++/86586 - -fcompare-debug=-Wsign-compare.
This patch limits constexpr folding for -Wsign-compare to only cases that we
would warn for without considering constant values, avoiding the folding in
the testcase in question.
gcc/c-family/
* c-warn.c (warn_for_sign_compare): Call fold_for_warn.
gcc/cp/
* typeck.c (cp_build_binary_op): Don't fold for -Wsign-compare.
From-SVN: r270136
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-warn.c | 3 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/i386/mv1.C | 2 |
5 files changed, 13 insertions, 9 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index cf73a1c..ae6b8a7 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-04-03 Jason Merrill <jason@redhat.com> + + PR c++/86586 - -fcompare-debug=-Wsign-compare. + * c-warn.c (warn_for_sign_compare): Call fold_for_warn. + 2019-04-01 Martin Sebor <msebor@redhat.com> PR c/89685 diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index d775ff8..4785887 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -2073,6 +2073,9 @@ warn_for_sign_compare (location_t location, else sop = orig_op1, uop = orig_op0; + sop = fold_for_warn (sop); + uop = fold_for_warn (uop); + STRIP_TYPE_NOPS (sop); STRIP_TYPE_NOPS (uop); base_type = (TREE_CODE (result_type) == COMPLEX_TYPE diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a224517..91d1431 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2019-04-03 Jason Merrill <jason@redhat.com> + PR c++/86586 - -fcompare-debug=-Wsign-compare. + * typeck.c (cp_build_binary_op): Don't fold for -Wsign-compare. + PR c++/89331 - ICE with offsetof in incomplete class. * semantics.c (finish_offsetof): Handle error_mark_node. * typeck.c (build_class_member_access_expr): Call diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 56def14..03b1402 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5486,14 +5486,7 @@ cp_build_binary_op (const op_location_t &location, && !enum_cast_to_int (orig_op0) && !enum_cast_to_int (orig_op1)) { - tree oop0 = maybe_constant_value (orig_op0); - tree oop1 = maybe_constant_value (orig_op1); - - if (TREE_CODE (oop0) != INTEGER_CST) - oop0 = cp_fully_fold (orig_op0); - if (TREE_CODE (oop1) != INTEGER_CST) - oop1 = cp_fully_fold (orig_op1); - warn_for_sign_compare (location, oop0, oop1, op0, op1, + warn_for_sign_compare (location, orig_op0, orig_op1, op0, op1, result_type, resultcode); } } diff --git a/gcc/testsuite/g++.target/i386/mv1.C b/gcc/testsuite/g++.target/i386/mv1.C index fc71347..9e36850 100644 --- a/gcc/testsuite/g++.target/i386/mv1.C +++ b/gcc/testsuite/g++.target/i386/mv1.C @@ -1,7 +1,7 @@ /* Test case to check if Multiversioning works. */ /* { dg-do run } */ /* { dg-require-ifunc "" } */ -/* { dg-options "-O2 -fPIC" } */ +/* { dg-options "-O2 -fPIC -fcompare-debug=-Wsign-compare" } */ #include <assert.h> |