Commit 2ddf4350 by Jason Merrill Committed by Jason Merrill

re PR c++/66585 (Internal compiler error when initialize field with lambda)

	PR c++/66585
	* pt.c (instantiate_class_template_1): Clear
	cp_unevaluated_operand and c_inhibit_evaluation_warnings.

From-SVN: r224684
parent 62245e6f
2015-06-18 Jason Merrill <jason@redhat.com>
PR c++/66585
* pt.c (instantiate_class_template_1): Clear
cp_unevaluated_operand and c_inhibit_evaluation_warnings.
2015-06-19 Jason Merrill <jason@redhat.com> 2015-06-19 Jason Merrill <jason@redhat.com>
PR c++/65880 PR c++/65880
......
...@@ -9215,12 +9215,20 @@ instantiate_class_template_1 (tree type) ...@@ -9215,12 +9215,20 @@ instantiate_class_template_1 (tree type)
it now. */ it now. */
push_deferring_access_checks (dk_no_deferred); push_deferring_access_checks (dk_no_deferred);
int saved_unevaluated_operand = cp_unevaluated_operand;
int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
fn_context = decl_function_context (TYPE_MAIN_DECL (type)); fn_context = decl_function_context (TYPE_MAIN_DECL (type));
/* Also avoid push_to_top_level for a lambda in an NSDMI. */ /* Also avoid push_to_top_level for a lambda in an NSDMI. */
if (!fn_context && LAMBDA_TYPE_P (type) && TYPE_CLASS_SCOPE_P (type)) if (!fn_context && LAMBDA_TYPE_P (type) && TYPE_CLASS_SCOPE_P (type))
fn_context = error_mark_node; fn_context = error_mark_node;
if (!fn_context) if (!fn_context)
push_to_top_level (); push_to_top_level ();
else
{
cp_unevaluated_operand = 0;
c_inhibit_evaluation_warnings = 0;
}
/* Use #pragma pack from the template context. */ /* Use #pragma pack from the template context. */
saved_maximum_field_alignment = maximum_field_alignment; saved_maximum_field_alignment = maximum_field_alignment;
maximum_field_alignment = TYPE_PRECISION (pattern); maximum_field_alignment = TYPE_PRECISION (pattern);
...@@ -9636,6 +9644,14 @@ instantiate_class_template_1 (tree type) ...@@ -9636,6 +9644,14 @@ instantiate_class_template_1 (tree type)
} }
} }
if (fn_context)
{
/* Restore these before substituting into the lambda capture
initializers. */
cp_unevaluated_operand = saved_unevaluated_operand;
c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
}
if (tree expr = CLASSTYPE_LAMBDA_EXPR (type)) if (tree expr = CLASSTYPE_LAMBDA_EXPR (type))
{ {
tree decl = lambda_function (type); tree decl = lambda_function (type);
......
// PR c++/66585
// { dg-do compile { target c++11 } }
class A {
template <typename, typename> using _Requires = int;
public:
template <typename _Functor, typename = _Requires<_Functor, void>>
A(_Functor);
};
template <class T> class B {
A f = [](T) {};
};
B<int> a;
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