[clang] [Clang] add long double test to cover constant expression evaluation (PR #175645)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 12 13:22:23 PST 2026
https://github.com/a-tarasyuk created https://github.com/llvm/llvm-project/pull/175645
Fixes https://github.com/llvm/llvm-project/pull/174113#discussion_r2683013358
---
This patch adds a test to cover the `long double` case during constant expression evaluation
>From 55ae6c7cb4c936f60e6f2f31b68dd15c107f4057 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk <oleksandr.tarasiuk at outlook.com>
Date: Mon, 12 Jan 2026 23:18:26 +0200
Subject: [PATCH] [Clang] add long double test to cover constant expression
evaluation
---
clang/test/Sema/constexpr.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c
index 16255c264423a..b5b62863cfdad 100644
--- a/clang/test/Sema/constexpr.c
+++ b/clang/test/Sema/constexpr.c
@@ -402,10 +402,17 @@ bool issue155507(v2int16_t a, v2int16_t b) {
constexpr bool b2 = (bool)nullptr;
_Static_assert(!b2);
-double ghissue173847(double a) {
+double gh173847_double(double a) {
double result = 3.0 / (a + 4.5 - 2.1 * 0.7);
return result;
}
-void ghissue173847_test() {
- constexpr float f_const = ghissue173847(2.0); // expected-error {{constexpr variable 'f_const' must be initialized by a constant expression}}
+
+long double gh173847_long_double(long double a) {
+ long double result = 3.0L / (a + 4.5L - 2.1L * 0.7L);
+ return result;
+}
+
+void gh173847_test() {
+ constexpr double d_const = gh173847_double(2.0); // expected-error {{constexpr variable 'd_const' must be initialized by a constant expression}}
+ constexpr long double ld_const = gh173847_long_double(2.0L); // expected-error {{constexpr variable 'ld_const' must be initialized by a constant expression}}
}
More information about the cfe-commits
mailing list