Author: Oleksandr T.
Date: 2026-01-13T10:03:25+02:00
New Revision: b685bf0032176b36d5f160025da21407b5ca03d8

URL: 
https://github.com/llvm/llvm-project/commit/b685bf0032176b36d5f160025da21407b5ca03d8
DIFF: 
https://github.com/llvm/llvm-project/commit/b685bf0032176b36d5f160025da21407b5ca03d8.diff

LOG: [Clang] add long double test to cover constant expression evaluation 
(#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

Added: 
    

Modified: 
    clang/test/Sema/constexpr.c

Removed: 
    


################################################################################
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}}
 }


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to