Commit e99d77c9 by Jason Merrill Committed by Jason Merrill

PR c++/85200 - ICE with constexpr if in generic lambda.

	* pt.c (extract_locals_r): Don't record the local specs of variables
	declared within the pattern.

From-SVN: r259127
parent 2ba16fd2
2018-04-05 Jason Merrill <jason@redhat.com>
PR c++/85200 - ICE with constexpr if in generic lambda.
* pt.c (extract_locals_r): Don't record the local specs of variables
declared within the pattern.
2018-04-05 Alexandre Oliva <aoliva@redhat.com>
PR c++/84979
......
......@@ -11597,8 +11597,12 @@ tsubst_binary_right_fold (tree t, tree args, tsubst_flags_t complain,
struct el_data
{
hash_set<tree> internal;
tree extra;
tsubst_flags_t complain;
el_data (tsubst_flags_t c)
: extra (NULL_TREE), complain (c) {}
};
static tree
extract_locals_r (tree *tp, int */*walk_subtrees*/, void *data_)
......@@ -11606,8 +11610,13 @@ extract_locals_r (tree *tp, int */*walk_subtrees*/, void *data_)
el_data &data = *reinterpret_cast<el_data*>(data_);
tree *extra = &data.extra;
tsubst_flags_t complain = data.complain;
if (tree spec = retrieve_local_specialization (*tp))
if (TREE_CODE (*tp) == DECL_EXPR)
data.internal.add (DECL_EXPR_DECL (*tp));
else if (tree spec = retrieve_local_specialization (*tp))
{
if (data.internal.contains (*tp))
/* Don't mess with variables declared within the pattern. */
return NULL_TREE;
if (TREE_CODE (spec) == NONTYPE_ARGUMENT_PACK)
{
/* Maybe pull out the PARM_DECL for a partial instantiation. */
......@@ -11658,7 +11667,7 @@ extract_locals_r (tree *tp, int */*walk_subtrees*/, void *data_)
static tree
extract_local_specs (tree pattern, tsubst_flags_t complain)
{
el_data data = { NULL_TREE, complain };
el_data data (complain);
cp_walk_tree_without_duplicates (&pattern, extract_locals_r, &data);
return data.extra;
}
......
// PR c++/85200
// { dg-additional-options -std=c++17 }
struct A{
constexpr operator int(){ return 0; }
};
template < typename >
void f(){
[](auto known){
if constexpr(constexpr int k = known);
}(A{});
}
int main(){
f<int>();
}
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