aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-10-06 17:56:23 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-10-06 17:56:23 +0000
commit46836b0e033c460d87146f5c635a4d026d2b77bb (patch)
tree31a6bbd29f3c460d9aa1e76daf7db63bc8532344 /gcc
parent1f27e0541577f3d1f95339ea0086b65a64bc123e (diff)
downloadgcc-46836b0e033c460d87146f5c635a4d026d2b77bb.zip
gcc-46836b0e033c460d87146f5c635a4d026d2b77bb.tar.gz
gcc-46836b0e033c460d87146f5c635a4d026d2b77bb.tar.bz2
re PR c++/67863 (-Wtautological-compare warns when it shouldn't)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/Wtautological-compare-4.c15
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 63ed047..623c3fc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 050d045..93e28dc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1e18963..0991ad0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..207c401
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wtautological-compare-4.c
@@ -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;
+}