forked from OSchip/llvm-project
Fix DeferredDiagnosticsEmitter for bug#45987
InOMPDeviceContext may be greater than 1. It needs to be clamp to 0 and 1 to be used as index for DoneMap.
This commit is contained in:
parent
439c8b2884
commit
3ef11346f3
|
@ -1539,7 +1539,7 @@ public:
|
|||
}
|
||||
|
||||
void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
|
||||
auto &Done = DoneMap[InOMPDeviceContext];
|
||||
auto &Done = DoneMap[InOMPDeviceContext > 0 ? 1 : 0];
|
||||
FunctionDecl *Caller = UsePath.empty() ? nullptr : UsePath.back();
|
||||
if ((!ShouldEmitRootNode && !S.getLangOpts().OpenMP && !Caller) ||
|
||||
S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// RUN: %clang_cc1 -triple x86_64 -verify=expected,dev -std=c++11\
|
||||
// RUN: -verify-ignore-unexpected=note \
|
||||
// RUN: -fopenmp -fopenmp-version=50 -o - %s
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
// Test no infinite recursion in DeferredDiagnosticEmitter.
|
||||
constexpr int foo(int *x) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int a = foo(&a);
|
||||
|
||||
// Test no crash when both caller and callee have target directives.
|
||||
int foo();
|
||||
|
||||
class B {
|
||||
public:
|
||||
void barB(int *isHost) {
|
||||
#pragma omp target map(tofrom: isHost)
|
||||
{
|
||||
*isHost = foo();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class A : public B {
|
||||
public:
|
||||
void barA(int *isHost) {
|
||||
#pragma omp target map(tofrom: isHost)
|
||||
{
|
||||
barB(isHost);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue