Commit 298434c9 by Jason Merrill Committed by Jason Merrill

PR c++/85807 - ICE with call in template NSDMI.

	* init.c (get_nsdmi): Use push_to/pop_from_top_level.
	* tree.c (bot_manip): Don't set_flags_from_callee in a template.

From-SVN: r260972
parent fbf5c1c6
2018-05-24 Jason Merrill <jason@redhat.com>
PR c++/85807 - ICE with call in template NSDMI.
* init.c (get_nsdmi): Use push_to/pop_from_top_level.
* tree.c (bot_manip): Don't set_flags_from_callee in a template.
2018-05-30 Jason Merrill <jason@redhat.com> 2018-05-30 Jason Merrill <jason@redhat.com>
PR c++/85873 - constant initializer_list array not in .rodata. PR c++/85873 - constant initializer_list array not in .rodata.
......
...@@ -577,6 +577,16 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) ...@@ -577,6 +577,16 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain)
DECL_INSTANTIATING_NSDMI_P (member) = 1; DECL_INSTANTIATING_NSDMI_P (member) = 1;
bool pushed = false;
if (!currently_open_class (DECL_CONTEXT (member)))
{
push_to_top_level ();
push_nested_class (DECL_CONTEXT (member));
pushed = true;
}
gcc_checking_assert (!processing_template_decl);
inject_this_parameter (DECL_CONTEXT (member), TYPE_UNQUALIFIED); inject_this_parameter (DECL_CONTEXT (member), TYPE_UNQUALIFIED);
start_lambda_scope (member); start_lambda_scope (member);
...@@ -599,6 +609,12 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) ...@@ -599,6 +609,12 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain)
nsdmi_inst->put (member, init); nsdmi_inst->put (member, init);
} }
if (pushed)
{
pop_nested_class ();
pop_from_top_level ();
}
input_location = sloc; input_location = sloc;
cp_unevaluated_operand = un; cp_unevaluated_operand = un;
} }
......
...@@ -3015,7 +3015,8 @@ bot_manip (tree* tp, int* walk_subtrees, void* data_) ...@@ -3015,7 +3015,8 @@ bot_manip (tree* tp, int* walk_subtrees, void* data_)
/* Make a copy of this node. */ /* Make a copy of this node. */
t = copy_tree_r (tp, walk_subtrees, NULL); t = copy_tree_r (tp, walk_subtrees, NULL);
if (TREE_CODE (*tp) == CALL_EXPR || TREE_CODE (*tp) == AGGR_INIT_EXPR) if (TREE_CODE (*tp) == CALL_EXPR || TREE_CODE (*tp) == AGGR_INIT_EXPR)
set_flags_from_callee (*tp); if (!processing_template_decl)
set_flags_from_callee (*tp);
if (data.clear_location && EXPR_HAS_LOCATION (*tp)) if (data.clear_location && EXPR_HAS_LOCATION (*tp))
SET_EXPR_LOCATION (*tp, input_location); SET_EXPR_LOCATION (*tp, input_location);
return t; return t;
......
...@@ -8,7 +8,7 @@ template<typename R, typename... Args> ...@@ -8,7 +8,7 @@ template<typename R, typename... Args>
struct function<R (Args...)> struct function<R (Args...)>
{ {
template<typename F> template<typename F>
function(const F&); function(const F&) { }
}; };
template<typename T> template<typename T>
......
...@@ -6,7 +6,7 @@ class A { ...@@ -6,7 +6,7 @@ class A {
public: public:
template <typename _Functor, typename = _Requires<_Functor, void>> template <typename _Functor, typename = _Requires<_Functor, void>>
A(_Functor); A(_Functor) { }
}; };
template <class T> class B { template <class T> class B {
A f = [](T) {}; A f = [](T) {};
......
// PR c++/85807
// { dg-do compile { target c++11 } }
template <class T>
struct limits
{
static T max();
};
template< class ScalarT = double >
struct value_statistics_t
{
double median = limits<double>::max();
};
template< class T > // required
value_statistics_t<> calc()
{
return {};
}
int main()
{
value_statistics_t<> wstats = calc<double>();
}
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