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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase:

namespace std {
template <bool> using a = struct _Any_data;
template <typename> struct function;
template <typename, typename> class F;
template <typename b, typename e, typename... c>
struct F<b(c...), e> {
  static b bar(const _Any_data &, c &&...) {}
};
template <typename b, typename... c> struct function<b(c...)> {
  template <typename, typename> using d = int;
  template <typename e, typename = d<a<!bool()>, void>, typename = d<e, void>>
  function(e);
  using h = b (*)(const _Any_data &, c &&...);
  h f;
};
template <typename b, typename... c>
template <typename e, typename, typename>
function<b(c...)>::function(e) { f = F<b(c...), e>::bar; }
}
class S {
  using G = std::function<double(double)>;
  void foo(const G & = [](double) {}, const G & = [](double) {});
};
void S::foo(const G &, const G &) { foo(); }

Seems the problem is that the method's parameter list is parsed multiple times,
once on the method declaration (line 22 above) and then again on the method
definition (line 24).
In LAMBDA_TYPE_EXTRA_SCOPE we record the PARM_DECLs of the declaration, but
DECL_ARGUMENTS will get the PARM_DECLs from the definition.

So, I think either we want during duplicate_decls adjust the PARM_DECLs in
LAMBDA_TYPE_EXTRA_SCOPE somehow from the old PARM_DECLs to the ones that won,
or store there for PARM_DECLs something different (instead of PARM_DECL say the
PARM_DECL or FUNCTION_DECL and the argument's number, or write_local_name needs
to use some other way to find map the PARM_DECLs into argument numbers (wonder
e.g. if it couldn't walk_tree the existing PARM_DECLs and corresponding
argument types including initializers for the entity, the same lambda shouldn't
appear in multiple of them).

Reply via email to