[OPENMP] Do not emit warning for implicitly declared target functions.

Since upcoming OpenMP 5.0 functions can be mapped implicitly as declare
target and we should not emit warnings for such functions.

llvm-svn: 331377
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 896954f..832f03b 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -12964,21 +12964,23 @@
   if (LD && !LD->hasAttr<OMPDeclareTargetDeclAttr>() &&
       ((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);
-      SemaRef.Diag(SL, diag::note_used_here) << SR;
-    } else {
-      const DeclContext *DC = LD->getDeclContext();
-      while (DC &&
-             (!isa<FunctionDecl>(DC) ||
-              !cast<FunctionDecl>(DC)->hasAttr<OMPDeclareTargetDeclAttr>()))
-        DC = DC->getParent();
-      if (DC)
-        return;
+    if (!isa<FunctionDecl>(LD)) {
+      if (LD->isOutOfLine()) {
+        SemaRef.Diag(LD->getLocation(), diag::warn_omp_not_in_target_context);
+        SemaRef.Diag(SL, diag::note_used_here) << SR;
+      } else {
+        const DeclContext *DC = LD->getDeclContext();
+        while (DC &&
+               (!isa<FunctionDecl>(DC) ||
+                !cast<FunctionDecl>(DC)->hasAttr<OMPDeclareTargetDeclAttr>()))
+          DC = DC->getParent();
+        if (DC)
+          return;
 
-      // Is not declared in target context.
-      SemaRef.Diag(LD->getLocation(), diag::warn_omp_not_in_target_context);
-      SemaRef.Diag(SL, diag::note_used_here) << SR;
+        // Is not declared in target context.
+        SemaRef.Diag(LD->getLocation(), diag::warn_omp_not_in_target_context);
+        SemaRef.Diag(SL, diag::note_used_here) << SR;
+      }
     }
     // Mark decl as declared target to prevent further diagnostic.
     auto *A = OMPDeclareTargetDeclAttr::CreateImplicit(