+2018-01-10 Marek Polacek <polacek@redhat.com>
+
+ PR c++/82541
+ * call.c (build_conditional_expr_1): Check complain before warning.
+ * pt.c (tsubst_copy_and_build) <case COND_EXPR>: Suppress
+ -Wduplicated-branches.
+
2018-01-10 Jakub Jelinek <jakub@redhat.com>
PR c++/81327
/* If the ARG2 and ARG3 are the same and don't have side-effects,
warn here, because the COND_EXPR will be turned into ARG2. */
if (warn_duplicated_branches
+ && (complain & tf_warning)
&& (arg2 == arg3 || operand_equal_p (arg2, arg3, 0)))
warning_at (EXPR_LOCATION (result), OPT_Wduplicated_branches,
"this condition has identical branches");
exp2 = RECUR (TREE_OPERAND (t, 2));
}
+ warning_sentinel s(warn_duplicated_branches);
RETURN (build_x_conditional_expr (EXPR_LOCATION (t),
cond, exp1, exp2, complain));
}
+2018-01-10 Marek Polacek <polacek@redhat.com>
+
+ PR c++/82541
+ * g++.dg/warn/Wduplicated-branches4.C: New test.
+
2018-01-10 Jakub Jelinek <jakub@redhat.com>
PR c++/81327
--- /dev/null
+// PR c++/82541
+// { dg-do compile }
+// { dg-options "-Wduplicated-branches" }
+
+template<int N>
+struct AR
+{
+ char a1[N > 0 ? N : 1]; // { dg-bogus "this condition has identical branches" }
+ char a2[N > 0 ? 1 : 1]; // { dg-warning "this condition has identical branches" }
+};
+
+int
+main ()
+{
+ AR<1> w;
+}