This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for bootstrap/68346 (bogus -Wtautological-compare)


With delayed folding we added folding for arguments to various warning functions, but that seems to be wrong for warn_tautological_cmp. In general, it's a tricky call; probably better long run will be for the warning functions to do their own folding if that's what they want.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 941058d18590e5c524ca97ad57f9ffdfcfec0469
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sat Nov 14 18:54:16 2015 +0000

    	PR bootstrap/68346
    	* call.c (build_new_op_1): Don't fold arguments to
    	warn_tautological_cmp.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230382 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 77c2936..8cdda62 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5741,7 +5741,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1,
 	maybe_warn_bool_compare (loc, code, fold (arg1),
 				 fold (arg2));
       if (complain & tf_warning && warn_tautological_compare)
-	warn_tautological_cmp (loc, code, fold (arg1), fold (arg2));
+	warn_tautological_cmp (loc, code, arg1, arg2);
       /* Fall through.  */
     case PLUS_EXPR:
     case MINUS_EXPR:
diff --git a/gcc/testsuite/g++.dg/warn/Wtautological-compare.C b/gcc/testsuite/g++.dg/warn/Wtautological-compare.C
new file mode 100644
index 0000000..451fd54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wtautological-compare.C
@@ -0,0 +1,7 @@
+// PR bootstrap/68346
+// { dg-options -Wtautological-compare }
+
+bool f(unsigned u)
+{
+  return ((unsigned)(int)u == u);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]