r331377 - [OPENMP] Do not emit warning for implicitly declared target functions.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed May 2 10:39:00 PDT 2018
Author: abataev
Date: Wed May 2 10:39:00 2018
New Revision: 331377
URL: http://llvm.org/viewvc/llvm-project?rev=331377&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=331377&r1=331376&r2=331377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed May 2 10:39:00 2018
@@ -12964,21 +12964,23 @@ static void checkDeclInTargetContext(Sou
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(
Modified: cfe/trunk/test/OpenMP/declare_target_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_messages.cpp?rev=331377&r1=331376&r2=331377&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp Wed May 2 10:39:00 2018
@@ -19,7 +19,7 @@ void f();
#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
-void c(); // expected-warning {{declaration is not declared in any declare target region}}
+void c();
void func() {} // expected-note {{'func' defined here}}
@@ -98,7 +98,7 @@ void foo(int p) {
g += object.method1();
g += object1.method() + p;
f();
- c(); // expected-note {{used here}}
+ c();
}
#pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}}
void foo1() {}
More information about the cfe-commits
mailing list