Commit d25a101f by Jason Merrill Committed by Jason Merrill

re PR c++/70543 (wrong non-const error for enable_if and constexpr function)

	PR c++/70543

	* pt.c (value_dependent_expression_p) [VAR_DECL]: A type-dependent
	initializer also makes the variable value-dependent.

From-SVN: r234990
parent 3ae9a8b7
2016-04-14 Jason Merrill <jason@redhat.com> 2016-04-14 Jason Merrill <jason@redhat.com>
PR c++/70543
* pt.c (value_dependent_expression_p) [VAR_DECL]: A type-dependent
initializer also makes the variable value-dependent.
PR c++/70648 PR c++/70648
* constexpr.c (cxx_eval_store_expression): Also copy * constexpr.c (cxx_eval_store_expression): Also copy
CONSTRUCTOR_NO_IMPLICIT_ZERO. CONSTRUCTOR_NO_IMPLICIT_ZERO.
......
...@@ -22670,6 +22670,7 @@ value_dependent_expression_p (tree expression) ...@@ -22670,6 +22670,7 @@ value_dependent_expression_p (tree expression)
&& (TREE_CODE (DECL_INITIAL (expression)) == TREE_LIST && (TREE_CODE (DECL_INITIAL (expression)) == TREE_LIST
/* cp_finish_decl doesn't fold reference initializers. */ /* cp_finish_decl doesn't fold reference initializers. */
|| TREE_CODE (TREE_TYPE (expression)) == REFERENCE_TYPE || TREE_CODE (TREE_TYPE (expression)) == REFERENCE_TYPE
|| type_dependent_expression_p (DECL_INITIAL (expression))
|| value_dependent_expression_p (DECL_INITIAL (expression)))) || value_dependent_expression_p (DECL_INITIAL (expression))))
return true; return true;
return false; return false;
......
// PR c++/70543
// { dg-do compile { target c++11 } }
template <typename>
struct X
{
template <unsigned int = 0>
static constexpr int
calc (void)
{
return 0;
}
static constexpr unsigned int value = calc ();
char foo[value];
};
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