https://github.com/loopacino updated https://github.com/llvm/llvm-project/pull/233521
>From 0b1873f10e720c03cbac5460750c5ff0a29129dc Mon Sep 17 00:00:00 2001 From: amtiwari <[email protected]> Date: Mon, 19 Oct 2026 14:04:48 -0400 Subject: [PATCH] fix_unsupported_types_in_GetValueRange --- clang/lib/Sema/SemaChecking.cpp | 9 ++++++++- .../test/OpenMP/flatten_floating_bounds_sema.c | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 clang/test/OpenMP/flatten_floating_bounds_sema.c diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 51506c62d4e35..628d8f950fc8c 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -12107,8 +12107,15 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E, // Try a full evaluation first. Expr::EvalResult result; - if (E->EvaluateAsRValue(result, C, InConstantContext)) + if (E->EvaluateAsRValue(result, C, InConstantContext)) { + // GetValueRange only handles integer-like values. + // Return nullopt for unsupported types. + if (!result.Val.isInt() && !result.Val.isVector() && + !result.Val.isComplexInt() && !result.Val.isLValue() && + !result.Val.isAddrLabelDiff()) + return std::nullopt; return GetValueRange(result.Val, GetExprType(E), MaxWidth); + } // I think we only want to look through implicit casts here; if the // user has an explicit widening cast, we should treat the value as diff --git a/clang/test/OpenMP/flatten_floating_bounds_sema.c b/clang/test/OpenMP/flatten_floating_bounds_sema.c new file mode 100644 index 0000000000000..1934d415989dd --- /dev/null +++ b/clang/test/OpenMP/flatten_floating_bounds_sema.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fopenmp -fopenmp-version=61 -fsyntax-only -verify %s +// expected-no-diagnostics + +// Flatten may create integer comparisons from floating trip counts. +// Guard against that to avoid assertion failures. +void test_floating_init(void) { +#pragma omp flatten + for (int i = 0; i < 2; ++i) + for (int j = 0.; j < 2; ++j) + ; +} + +void test_floating_bound(void) { +#pragma omp flatten + for (int i = 0; i < 2; ++i) + for (int j = 0; j < 2.; ++j) + ; +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
