re PR c++/67863 (-Wtautological-compare warns when it shouldn't)
authorMarek Polacek <polacek@redhat.com>
Tue, 6 Oct 2015 17:56:23 +0000 (17:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 6 Oct 2015 17:56:23 +0000 (17:56 +0000)
PR c++/67863
* call.c (build_conditional_expr_1): Build the COND_EXPR with
a location.

* c-c++-common/Wtautological-compare-4.c: New test.

From-SVN: r228540

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wtautological-compare-4.c [new file with mode: 0644]

index 63ed0473f2dabf44369e3c4c9fa644bba0965e23..623c3fcc55cfa07f4bc14e6105168d36d863447e 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/67863
+       * call.c (build_conditional_expr_1): Build the COND_EXPR with
+       a location.
+
 2015-10-05  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/53856
index 050d04574834e69c2193442e943ef2cddb7a1100..93e28dcadd6fa5ed5c99ea85e5865663fc12d842 100644 (file)
@@ -5144,7 +5144,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
     return error_mark_node;
 
  valid_operands:
-  result = build3 (COND_EXPR, result_type, arg1, arg2, arg3);
+  result = build3_loc (loc, COND_EXPR, result_type, arg1, arg2, arg3);
   if (!cp_unevaluated_operand)
     /* Avoid folding within decltype (c++/42013) and noexcept.  */
     result = fold_if_not_in_template (result);
index 1e1896398d42d3b5807fd1d0b76a97e742cadba2..0991ad0c52a63c62bceea53059666baf774cf6b0 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/67863
+       * c-c++-common/Wtautological-compare-4.c: New test.
+
 2015-10-05  Michael Meissner  <meissner@linux.vnet.ibm.com>
            Peter Bergner <bergner@vnet.ibm.com>
 
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-4.c b/gcc/testsuite/c-c++-common/Wtautological-compare-4.c
new file mode 100644 (file)
index 0000000..207c401
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR c++/67863 */
+/* { dg-do compile } */
+/* { dg-options "-Wtautological-compare" } */
+
+extern int e;
+#define A (e ? 4 : 8)
+#define B (e ? 4 : 8)
+
+int
+fn (void)
+{
+  if (A <= B)
+    return 1;
+  return 0;
+}