On Tue, Jul 21, 2020 at 02:05:36PM +0200, Tobias Burnus wrote:
> This code is both called by C and C++ – and for C++. And I would like
> to permit "hint(N)" where N is a template parameter.
> 
> Hence, I added another:
>   '&& TREE_CODE (OMP_CLAUSE_HINT_EXPR (clauses)) == INTEGER_CST'
> to your proposal.

Oops, but that just shows that we don't really handle critical in such case
correctly, because nothing will then try to verify the value after
instantiation.

The usual way how to handle instantiation is if something is type (or
value) dependent (depending on what it is), we punt early on some checks and
usually just always for processing_template_decl or perhaps just when
something is dependent create some temporary tree and then redo the checks
during instantiation.

While if c_finish_omp_critical is careful not to do anything that would
be upset if something in it contains C++ FE specific trees and is dependent
we can perhaps use it, I think we need to handle OMP_CRITICAL differently in
pt.c then from what it does now, prepare arguments for c_finish_omp_critical
and call it again.

Consider:
template <int N>
void
foo ()
{
  #pragma omp critical hint (N)
  ;
}
// So no diagnostics above during processing_template_decl
void
bar ()
{
  foo <0> (); // OK
  foo <1> (); // This should be diagnosed during instantiation
}

        Jakub

Reply via email to