This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gomp] Fix omp for scoping in templates


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]