[clang] [Clang] Add additional tests for constexpr initialization (PR #181965)

Samrudh Nelli via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 03:56:15 PDT 2026


https://github.com/SamrudhNelli updated https://github.com/llvm/llvm-project/pull/181965

>From d44048bbd6fdb18cf9a200642f26e79080ea2ac4 Mon Sep 17 00:00:00 2001
From: Samrudh Nelli <samrudhnelli at gmail.com>
Date: Wed, 18 Feb 2026 11:42:51 +0530
Subject: [PATCH] [Clang] Add additional tests for constexpr initialization

---
 clang/test/Sema/constexpr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c
index 04da0f56a741d..3a6b49fd90748 100644
--- a/clang/test/Sema/constexpr.c
+++ b/clang/test/Sema/constexpr.c
@@ -313,6 +313,12 @@ constexpr int *V84 = 42;
 constexpr int *V85 = nullptr;
 constexpr int *V91 = 0.0; 
 // expected-error at -1 {{initializing 'int *const' with an expression of incompatible type 'double'}}
+constexpr int *V92 = 0.0f;
+// expected-error at -1 {{initializing 'int *const' with an expression of incompatible type 'float'}}
+constexpr int *V93 = 0e0;
+// expected-error at -1 {{initializing 'int *const' with an expression of incompatible type 'double'}}
+constexpr int *V94 = 0x0p0;
+// expected-error at -1 {{initializing 'int *const' with an expression of incompatible type 'double'}}
 
 // Check that constexpr variables should not be VLAs.
 void f6(const int P1) {



More information about the cfe-commits mailing list