This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Diagnose function name on the link clause
ClosedPublic

Authored by kkwli0 on Dec 7 2017, 9:47 AM.

Details

Summary

This patch is to add diagnose when a function name is specified on the link clause. According to the OpenMP spec, only the list items that exclude the function name are allowed on the link clause.

void foo() {}
#pragma omp declare target link(foo)
d2.c:2:33: error: function name is not allowed in 'link' clause
#pragma omp declare target link(foo)
                                ^
d2.c:1:6: note: 'foo' defined here
void foo() {}
     ^
1 error generated.

Diff Detail

Repository
rL LLVM

Event Timeline

kkwli0 created this revision.Dec 7 2017, 9:47 AM
ABataev added inline comments.Dec 7 2017, 10:19 AM
lib/Sema/SemaOpenMP.cpp
12576 ↗(On Diff #125983)

I would like to see this some in check functions, like checkDeclIsAllowedInOpenMPTarget rather than here

kkwli0 marked an inline comment as done.Dec 7 2017, 1:06 PM
kkwli0 added inline comments.
lib/Sema/SemaOpenMP.cpp
12576 ↗(On Diff #125983)

Sure. I will move the check into checkDeclIsAllowedInOpenMPTarget.

kkwli0 updated this revision to Diff 126025.Dec 7 2017, 1:08 PM
kkwli0 marked an inline comment as done.
ABataev added inline comments.Dec 8 2017, 8:51 AM
lib/Sema/SemaOpenMP.cpp
12671 ↗(On Diff #126025)

You can get DeclarationNameInfo from the FunctionDecl:

FD->getNameInfo()
kkwli0 added inline comments.Dec 8 2017, 10:59 AM
lib/Sema/SemaOpenMP.cpp
12671 ↗(On Diff #126025)

This FD->getNameInfo() will only give the name info from the function definition. What we need here is the name info for 'foo' that appears on the pragma in order to give us

d2.c:2:33: error: function name is not allowed in 'link' clause
#pragma omp declare target link(foo)
                                ^
ABataev added inline comments.Dec 8 2017, 11:59 AM
lib/Sema/SemaOpenMP.cpp
12671 ↗(On Diff #126025)

Then just pass SourceLocation

kkwli0 marked an inline comment as done.Dec 8 2017, 1:48 PM
kkwli0 added inline comments.
lib/Sema/SemaOpenMP.cpp
12671 ↗(On Diff #126025)

Sure.

kkwli0 updated this revision to Diff 126217.Dec 8 2017, 3:14 PM
kkwli0 marked an inline comment as done.
This revision is now accepted and ready to land.Dec 11 2017, 6:21 AM
This revision was automatically updated to reflect the committed changes.