Skip to content

Commit 993ee85

Browse files
committed
Give a warning when defining a task outline but exists a previous declaration that is not.
Closes llvm#84
1 parent 7d1cec4 commit 993ee85

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

+3
Original file line numberDiff line numberDiff line change
@@ -11003,6 +11003,9 @@ def warn_oss_decl_shadow :
1100311003
"type alias in %2}1">;
1100411004
def warn_oss_decl_shadow_uncaptured_local :
1100511005
Warning<warn_oss_decl_shadow.Text>;
11006+
def warn_oss_call_may_not_be_task :
11007+
Warning<"function has already been declared earlier as a regular (non-task) function, "
11008+
"any calls prior to this point will not create tasks">;
1100611009
} // end of OmpSs component.
1100711010

1100811011

clang/lib/Sema/SemaOmpSs.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,12 @@ Sema::DeclGroupPtrTy Sema::ActOnOmpSsDeclareTaskDirective(
21922192
return DeclGroupPtrTy();
21932193
}
21942194

2195+
if (FD->getFirstDecl() != FD) {
2196+
Diag(ADecl->getLocation(), diag::warn_oss_call_may_not_be_task);
2197+
Diag(FD->getFirstDecl()->getLocation(), diag::note_previous_decl)
2198+
<< FD->getFirstDecl();
2199+
}
2200+
21952201
auto ParI = FD->param_begin();
21962202
while (ParI != FD->param_end()) {
21972203
QualType Type = (*ParI)->getType();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -verify -fompss-2 -ferror-limit 100 %s -Wuninitialized
2+
static void foo(int *p); // expected-note {{'foo' declared here}}
3+
static void foo(int *p);
4+
5+
int main() {
6+
int n;
7+
foo(&n);
8+
#pragma oss taskwait
9+
}
10+
11+
#pragma oss task inout(*p)
12+
static void foo(int *p) { } // expected-warning {{function has already been declared earlier as a regular (non-task) function, any calls prior to this point will not create tasks}}

0 commit comments

Comments
 (0)