Commit f1eac182 by Jason Merrill Committed by Jason Merrill

re PR c++/64647 ([C++14] std::__max_element contains code not allowed in constexpr function)

	PR c++/64647
	* constexpr.c (ensure_literal_type_for_constexpr_object): Don't
	give a hard error in a template instantiation.

From-SVN: r219965
parent 6875457f
2015-01-21 Jason Merrill <jason@redhat.com>
PR c++/64647
* constexpr.c (ensure_literal_type_for_constexpr_object): Don't
give a hard error in a template instantiation.
2015-01-21 Richard Biener <rguenther@suse.de>
PR middle-end/64313
......
......@@ -102,15 +102,21 @@ ensure_literal_type_for_constexpr_object (tree decl)
else if (!literal_type_p (type))
{
if (DECL_DECLARED_CONSTEXPR_P (decl))
error ("the type %qT of constexpr variable %qD is not literal",
type, decl);
{
error ("the type %qT of constexpr variable %qD is not literal",
type, decl);
explain_non_literal_class (type);
}
else
{
error ("variable %qD of non-literal type %qT in %<constexpr%> "
"function", decl, type);
if (!DECL_TEMPLATE_INSTANTIATION (current_function_decl))
{
error ("variable %qD of non-literal type %qT in %<constexpr%> "
"function", decl, type);
explain_non_literal_class (type);
}
cp_function_chain->invalid_constexpr = true;
}
explain_non_literal_class (type);
return NULL;
}
}
......
// PR c++/64647
// { dg-do compile { target c++14 } }
template<typename T>
constexpr T foo(T t)
{
T tt = t;
return tt;
}
struct X
{
X() { }
};
int main()
{
X x;
foo(x);
}
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