This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] Fix omp for scoping in templates
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Diego Novillo <dnovillo at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 26 Oct 2005 05:06:27 -0400
- Subject: Re: [gomp] Fix omp for scoping in templates
- References: <20051026084532.GK16034@devserv.devel.redhat.com> <20051026085412.GA17973@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Oct 26, 2005 at 01:54:12AM -0700, Richard Henderson wrote:
> On Wed, Oct 26, 2005 at 04:45:32AM -0400, Jakub Jelinek wrote:
> > * cp-tree.h (finish_omp_for): Add PRE_BODY argument.
> > * semantics.c (finish_omp_for): Likewise. If processing template
> > and PRE_BODY is not empty, also defer it. Set OMP_FOR_PRE_BODY
> > to PRE_BODY if deferring or add it into the current statement list.
> > * parser.c (cp_parser_omp_for_loop): Expand optional DECL_EXPRs
> > into PRE_BODY statement list. Pass it to finish_omp_for.
> > * pt.c (tsubst_expr) <case OMP_FOR>: tsubst_expr also OMP_FOR_PRE_BODY
> > into PRE_BODY stmt list, pass it to finish_omp_for. Put all the
> > statements into sk_omp scope.
> > * g++.dg/gomp/for-15.C: New test.
>
> I guess I like the first patch. I don't see why you touched the
> c-common bits in the second patch; afaict, you always pass null.
if (pre_body != NULL && ! IS_EMPTY_STMT (pre_body) && processing_template_decl)
I'm passing non-NULL (usually a DECL_EXPR).
Consider e.g.:
template<typename T> void foo ()
{
#pragma omp for
for (unsigned int i = 0; i < 10; i++); // { dg-warning "is unsigned" }
#pragma omp for
for (int j = 0; ; j++); // { dg-error "missing controlling predicate" }
#pragma omp for
for (T k = 0; ; k++); // Error here is emitted only during instantiation
}
When the template is never used, only with the second patch we'll issue
the diagnostics.
Jakub