https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124490

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
decl_dependent_p already has:
  /* for-range-declaration of expansion statement as well as variable
     declarations in the expansion statement body when the expansion statement
     is not inside a template still need to be treated as dependent during
     parsing.  When the body is instantiated, in_expansion_stmt will be already
     false.  */
  if (VAR_P (orig_decl) && in_expansion_stmt && decl == current_function_decl)
    return true;
The problem is that this doesn't trigger here, orig_decl is d above, decl is
the foo
FUNCTION_DECL and current_function_decl is the lambda.
So, wonder if it doesn't have to be decl is a FUNCTION_DECL which is or is
nested in the (outermost) expansion statement's function.
Thus make in_expansion_stmt a tree rather than bool and if in_expansion_stmt
walk the context chain and see if we reach in_expanion_stmt or not.

Reply via email to