This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Diagnose undeclared variables on declare target clause
ClosedPublic

Authored by kkwli0 on Nov 28 2017, 3:53 PM.

Details

Summary

Clang asserts on any undeclared variables on the to or link clause in the declare target directive. The patch is to properly diagnose the error.

// foo1 and foo2 are not declared
#pragma omp declare target to(foo1)
#pragma omp declare target link(foo2)

The diagnostic messages are:

d1.cpp:3:31: error: use of undeclared identifier 'foo1'
#pragma omp declare target to(foo1)
                              ^
d1.cpp:4:33: error: use of undeclared identifier 'foo2'
#pragma omp declare target link(foo2)
                                ^
2 errors generated.

Diff Detail

Repository
rL LLVM

Event Timeline

kkwli0 created this revision.Nov 28 2017, 3:53 PM
kkwli0 added a subscriber: cfe-commits.
ABataev requested changes to this revision.Nov 29 2017, 6:22 AM

I'm unable to reproduce a crash, the test works correctly even without you patch

This revision now requires changes to proceed.Nov 29 2017, 6:22 AM
kkwli0 edited the summary of this revision. (Show Details)Nov 29 2017, 1:48 PM

The original case has the variables named "foo1" and foo2". Using "foo1" or "foo2" causes the assert! I update the description.

kkwli0 updated this revision to Diff 124811.Nov 29 2017, 1:54 PM
kkwli0 edited edge metadata.

The assert occurs in VarOrFuncDeclFilterCCC::ValidateCandidate when clang::Sema::CorrectTypo is called.

This revision is now accepted and ready to land.Nov 30 2017, 6:11 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.