public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: Incremental fix for g++.dg/gomp/for-21.C [PR84469]
Date: Wed, 30 Nov 2022 13:52:08 -0500	[thread overview]
Message-ID: <fc72794f-bac3-90dd-d36e-9dc84bdb8e39@redhat.com> (raw)
In-Reply-To: <Y4d77q1VhYaOVFVm@tucnak>

On 11/30/22 10:51, Jakub Jelinek wrote:
> On Tue, Nov 29, 2022 at 11:05:33PM +0100, Jakub Jelinek wrote:
>> On Tue, Nov 29, 2022 at 04:38:50PM -0500, Jason Merrill wrote:
>>>> --- gcc/testsuite/g++.dg/gomp/for-21.C.jj	2020-01-12 11:54:37.178401867 +0100
>>>> +++ gcc/testsuite/g++.dg/gomp/for-21.C	2022-11-29 13:06:59.038410557 +0100
>>>> @@ -54,9 +54,9 @@ 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 (auto [i, j, k] : a)			// { dg-error "use of 'i' before deduction of 'auto'" }
>>>>        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 }
>>>> +      ;						// { dg-error "use of 'k' before deduction of 'auto'" "" { target *-*-* } .-1 }
>>>
>>> Hmm, this error is surprising: since the initializer is non-dependent, we
>>> should have deduced immediately.  I'd expect the same error as in the
>>> non-structured-binding cases, "* expression refers to iteration variable".
>>
>> The reason was just to be consistent what is (unfortunately) emitted
>> in the other cases (!processing_template_decl or type dependent).
>> I guess I could try how much work would it be to deduce it sooner, but
>> generally it is pretty corner case, people rarely do this in OpenMP code.
> 
> I had a look at that today, but it would be pretty hard.  The thing is
> we must emit all the associated code for all the range for loops in
> OpenMP loops at a different spot.  So, the only possibility I see would
> be if we during parsing of a range for loop inside of the OpenMP loop nest
> we don't do the cp_finish_omp_range_for stuff to avoid e.g. cp_finish_decl,
> but instead
>    build_x_indirect_ref (input_location, begin, RO_UNARY_STAR,
> 			NULL_TREE, tf_none)
> and if that gives a non-dependent type, temporarily overwrite TREE_TYPE
> of the decl and if it is structured binding, temporarily
> ++processing_template_decl and cp_finish_decomp, then after parsing all the
> associated loop headers we revert that (and ditto for instantiation of
> OpenMP loops).

It looks like we're already deducing the type for the underlying S 
variable in cp_convert_omp_range_for, we just aren't updating the types 
of the individual bindings.

Jason


  reply	other threads:[~2022-11-30 18:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 12:32 Jakub Jelinek
2022-11-29 21:38 ` Jason Merrill
2022-11-29 22:05   ` Jakub Jelinek
2022-11-30 15:51     ` Jakub Jelinek
2022-11-30 18:52       ` Jason Merrill [this message]
2022-12-01 10:32         ` [PATCH] c++, v2: " Jakub Jelinek
2022-12-01 18:21           ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc72794f-bac3-90dd-d36e-9dc84bdb8e39@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).