]> granicus.if.org Git - clang/commitdiff
[OPENMP] Do not emit warning about non-declared target function params.
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 30 Apr 2018 18:28:08 +0000 (18:28 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 30 Apr 2018 18:28:08 +0000 (18:28 +0000)
We should not emit warning that the parameters are not marked as declare
target, these declaration are local and cannot be marked as declare
target.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331211 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/declare_target_messages.cpp

index 6220e86b5442ac9d5ada4990d65a1db7513a463e..896954fcf09b2cb692ee9c9cff600d7cc3b5e0c0 100644 (file)
@@ -12962,7 +12962,7 @@ static void checkDeclInTargetContext(SourceLocation SL, SourceRange SR,
   if (!LD)
     LD = D;
   if (LD && !LD->hasAttr<OMPDeclareTargetDeclAttr>() &&
-      (isa<VarDecl>(LD) || isa<FunctionDecl>(LD))) {
+      ((isa<VarDecl>(LD) && !isa<ParmVarDecl>(LD)) || isa<FunctionDecl>(LD))) {
     // Outlined declaration is not declared target.
     if (LD->isOutOfLine()) {
       SemaRef.Diag(LD->getLocation(), diag::warn_omp_not_in_target_context);
index 3286a29dc4182054f923818298b52ba936512575..72ea33cfc82d1cfb0b75a5f9d3b150ff479da573 100644 (file)
@@ -88,7 +88,7 @@ int C::method1() {
   return 0;
 }
 
-void foo() {
+void foo(int p) {
   a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}}
   b = 0; // expected-note {{used here}}
   t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}}
@@ -96,7 +96,7 @@ void foo() {
   VC object1;
   g = object.method();
   g += object.method1();
-  g += object1.method();
+  g += object1.method() + p;
   f();
   c(); // expected-note {{used here}}
 }
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
 #pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}}
   int v;
 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
-  foo();
+  foo(v);
   return (0);
 }