Commit 0e45c664 by Marek Polacek Committed by Marek Polacek

re PR c++/85695 (if constexpr misevaluates typedefed type value)

	PR c++/85695
	* semantics.c (finish_if_stmt_cond): See through typedefs.

	* g++.dg/cpp1z/constexpr-if22.C: New test.

From-SVN: r260049
parent 3b275e65
2018-05-08 Marek Polacek <polacek@redhat.com>
PR c++/85695
* semantics.c (finish_if_stmt_cond): See through typedefs.
2018-05-07 Jason Merrill <jason@redhat.com>
PR c++/85646 - lambda visibility.
......
......@@ -736,7 +736,7 @@ finish_if_stmt_cond (tree cond, tree if_stmt)
&& !instantiation_dependent_expression_p (cond)
/* Wait until instantiation time, since only then COND has been
converted to bool. */
&& TREE_TYPE (cond) == boolean_type_node)
&& TYPE_MAIN_VARIANT (TREE_TYPE (cond)) == boolean_type_node)
{
cond = instantiate_non_dependent_expr (cond);
cond = cxx_constant_value (cond, NULL_TREE);
......
2018-05-08 Marek Polacek <polacek@redhat.com>
PR c++/85695
* g++.dg/cpp1z/constexpr-if22.C: New test.
2018-05-08 Uros Bizjak <ubizjak@gmail.com>
PR target/85693
......
// PR c++/85695
// { dg-options -std=c++17 }
template <typename T, T v>
struct integral_constant {
using value_type = T;
static constexpr const value_type value = v;
constexpr operator value_type (void) const { return value; }
};
template <typename T> struct is_trivial
: public integral_constant<bool, __is_trivial(T)> {};
template <typename T>
T clone_object (const T& p)
{
if constexpr (is_trivial<T>::value)
return p;
else
return p.clone();
}
int main (void) { return clone_object(0); }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment