+2019-03-06 Jason Merrill <jason@redhat.com>
+
+ PR c++/89576 - if constexpr of lambda capture.
+ * semantics.c (maybe_convert_cond): Do convert a non-dependent
+ condition in a template.
+ * typeck.c (condition_conversion): Handle being called in a
+ template.
+
2019-03-06 Marek Polacek <polacek@redhat.com>
PR c++/87378 - bogus -Wredundant-move warning.
return NULL_TREE;
/* Wait until we instantiate templates before doing conversion. */
- if (processing_template_decl)
+ if (type_dependent_expression_p (cond))
return cond;
- if (warn_sequence_point)
+ if (warn_sequence_point && !processing_template_decl)
verify_sequence_points (cond);
/* Do the conversion. */
return c_common_truthvalue_conversion (input_location, expr);
}
-/* Just like cp_truthvalue_conversion, but we want a CLEANUP_POINT_EXPR. */
+/* Just like cp_truthvalue_conversion, but we want a CLEANUP_POINT_EXPR. This
+ is a low-level function; most callers should use maybe_convert_cond. */
tree
condition_conversion (tree expr)
{
tree t;
- /* Anything that might happen in a template should go through
- maybe_convert_cond. */
- gcc_assert (!processing_template_decl);
t = perform_implicit_conversion_flags (boolean_type_node, expr,
tf_warning_or_error, LOOKUP_NORMAL);
- t = fold_build_cleanup_point_expr (boolean_type_node, t);
+ if (!processing_template_decl)
+ t = fold_build_cleanup_point_expr (boolean_type_node, t);
return t;
}