Skip to content

Commit 2502f89

Browse files
committed
[OPENMP]Fix PR48387: disable warning messages caused by internal conversions.
Compiler needs to convert some of the loop iteration variables/conditions to different types for better codegen and it may lead to spurious warning messages about implicit signed/unsigned conversions. Differential Revision: https://reviews.llvm.org/D92655
1 parent 4a8b5e9 commit 2502f89

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,6 +4196,7 @@ static OMPCapturedExprDecl *buildCaptureDecl(Sema &S, IdentifierInfo *Id,
41964196
if (!WithInit)
41974197
CED->addAttr(OMPCaptureNoInitAttr::CreateImplicit(C));
41984198
S.CurContext->addHiddenDecl(CED);
4199+
Sema::TentativeAnalysisScope Trap(S);
41994200
S.AddInitializerToDecl(CED, Init, /*DirectInit=*/false);
42004201
return CED;
42014202
}
@@ -7580,6 +7581,7 @@ std::pair<Expr *, Expr *> OpenMPIterationSpaceChecker::buildMinMaxValues(
75807581
if (!Diff.isUsable())
75817582
return std::make_pair(nullptr, nullptr);
75827583

7584+
Sema::TentativeAnalysisScope Trap(SemaRef);
75837585
Diff = SemaRef.ActOnFinishFullExpr(Diff.get(), /*DiscardedValue=*/false);
75847586
if (!Diff.isUsable())
75857587
return std::make_pair(nullptr, nullptr);

clang/test/OpenMP/for_ast_print.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
1+
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wsign-conversion | FileCheck %s
22
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
33
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
44

5-
// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
5+
// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wsign-conversion | FileCheck %s
66
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
77
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
88
// expected-no-diagnostics
@@ -223,9 +223,9 @@ int main(int argc, char **argv) {
223223
// CHECK: static int a;
224224
#pragma omp for schedule(guided, argc) reduction(+:argv[0][:1]) order(concurrent)
225225
// CHECK-NEXT: #pragma omp for schedule(guided, argc) reduction(+: argv[0][:1]) order(concurrent)
226-
for (int i = 0; i < 2; ++i)
226+
for (int i = argc; i < c; ++i)
227227
a = 2;
228-
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
228+
// CHECK-NEXT: for (int i = argc; i < c; ++i)
229229
// CHECK-NEXT: a = 2;
230230
#pragma omp parallel
231231
#pragma omp for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(3) schedule(auto) ordered nowait linear(g:-1) reduction(task, +:e)

0 commit comments

Comments
 (0)