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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The patch unfortunately regresses the OpenMP g++.dg/gomp/for-21.C test:
template <int N>
void
f6 (S (&a)[10])
{
  #pragma omp for collapse (2)
  for (auto [i, j, k] : a)                      // { dg-error "use of 'i'
before deduction of 'auto'" "" { target *-*-* } .-1 }
    for (int l = i; l < j; l += k)              // { dg-error "use of 'j'
before deduction of 'auto'" }
      ;                                         // { dg-error "use of 'k'
before deduction of 'auto'" "" { target *-*-* } .-3 }
}
...
  S c[10] {};
  f6 <0> (c);
where the bug is no longer diagnosed.  When not in a template or when the
range for decl is type dependent, it works because the invalid uses are
diagnosed by finish_id_expression -> mark_used and complain about uses of auto
before it is deduced, but in the above case a is not type dependent, mark_used
doesn't complain about uses of auto when processing_template_decl and the new
code deduces a and i/j/k before finish_id_expression is called on it again
during instantiation.
So, I'll need to add further code to handle this right.

Reply via email to