Skip to content

Avoid unevaluated implicit private #92055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3757,7 +3757,8 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
void VisitDeclRefExpr(DeclRefExpr *E) {
if (TryCaptureCXXThisMembers || E->isTypeDependent() ||
E->isValueDependent() || E->containsUnexpandedParameterPack() ||
E->isInstantiationDependent())
E->isInstantiationDependent() ||
E->isNonOdrUse() == clang::NOUR_Unevaluated)
return;
if (auto *VD = dyn_cast<VarDecl>(E->getDecl())) {
// Check the datasharing rules for the expressions in the clauses.
Expand Down
41 changes: 41 additions & 0 deletions clang/test/OpenMP/task_ast_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify -Wno-vla %s -ast-print | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -ast-dump %s | FileCheck %s --check-prefix=DUMP
// expected-no-diagnostics

#ifndef HEADER
Expand Down Expand Up @@ -208,4 +209,44 @@ int main(int argc, char **argv) {
extern template int S<int>::TS;
extern template long S<long>::TS;

// DUMP-LABEL: FunctionDecl {{.*}} implicit_firstprivate
void
implicit_firstprivate() {

#pragma omp parallel num_threads(1)
{
int i = 0;
// DUMP: OMPTaskDirective
// DUMP-NEXT: OMPFirstprivateClause
// DUMP-NOT: DeclRefExpr {{.+}} 'i' {{.+}} non_odr_use_unevaluated
// DUMP: DeclRefExpr {{.+}} 'i' 'int' refers_to_enclosing_variable_or_capture
// DUMP: CapturedStmt
// DUMP: BinaryOperator {{.+}} 'int' lvalue '='
// DUMP-NEXT: DeclRefExpr {{.+}} 'j' 'int'
// DUMP: DeclRefExpr {{.+}} 'i' {{.+}} non_odr_use_unevaluated
#pragma omp task
{
int j = sizeof(i);
j = i;
}
}
}

// DUMP-LABEL: FunctionDecl {{.*}} no_implicit_firstprivate
void
no_implicit_firstprivate() {

#pragma omp parallel num_threads(1)
{
int i = 0;
// DUMP: OMPTaskDirective
// DUMP-NEXT: CapturedStmt
// DUMP: DeclRefExpr {{.+}} 'i' {{.+}} non_odr_use_unevaluated refers_to_enclosing_variable_or_capture
#pragma omp task
{
int j = sizeof(i);
}
}
}

#endif
Loading