clang-omp / clang

clang with OpenMP 3.1 and some elements of OpenMP 4.0 support
clang-omp.github.com
Other
91 stars 15 forks source link

Fix DSA for function parameters. #40

Closed viroulep closed 10 years ago

viroulep commented 10 years ago

Function parameters are erroneously detected as shared.

This test comes from the gcc testsuite (omp-single-3), and clang-omp (a65de2d1) complains that a and b are not private while they actually are. The error message is the following : error: copyprivate variable must be threadprivate or private in the enclosing context

extern void abort (void);

void
single (int a, int b)
{
  #pragma omp single copyprivate(a) copyprivate(b)
    {
      a = b = 5;
    }

  if (a != b)
    abort ();
}

int main()
{
  #pragma omp parallel
    single (1, 2);

  return 0;
}

This happens because isFunctionOrMethodVarDecl only check for Decl::Var and not for Decl::ParmVar. According to the documentation it's the expected behaviour, so I guess the additional check belongs in SemaOpenMP.