Skip to content

Commit d0df36a

Browse files
committed
[OPENMP] Do not emit warning about non-declared target function params.
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. llvm-svn: 331211
1 parent 1babf5f commit d0df36a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12962,7 +12962,7 @@ static void checkDeclInTargetContext(SourceLocation SL, SourceRange SR,
1296212962
if (!LD)
1296312963
LD = D;
1296412964
if (LD && !LD->hasAttr<OMPDeclareTargetDeclAttr>() &&
12965-
(isa<VarDecl>(LD) || isa<FunctionDecl>(LD))) {
12965+
((isa<VarDecl>(LD) && !isa<ParmVarDecl>(LD)) || isa<FunctionDecl>(LD))) {
1296612966
// Outlined declaration is not declared target.
1296712967
if (LD->isOutOfLine()) {
1296812968
SemaRef.Diag(LD->getLocation(), diag::warn_omp_not_in_target_context);

clang/test/OpenMP/declare_target_messages.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ int C::method1() {
8888
return 0;
8989
}
9090

91-
void foo() {
91+
void foo(int p) {
9292
a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}}
9393
b = 0; // expected-note {{used here}}
9494
t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}}
9595
C object;
9696
VC object1;
9797
g = object.method();
9898
g += object.method1();
99-
g += object1.method();
99+
g += object1.method() + p;
100100
f();
101101
c(); // expected-note {{used here}}
102102
}
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
119119
#pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}}
120120
int v;
121121
#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
122-
foo();
122+
foo(v);
123123
return (0);
124124
}
125125

0 commit comments

Comments
 (0)