https://github.com/SamrudhNelli created https://github.com/llvm/llvm-project/pull/181965
Add initialization tests for `0.0f`, `0e0`, `0x0p0`. Suggested by @shafik in #180376 >From 9e8bcf6b421e0f285be990f0e667bf579949e618 Mon Sep 17 00:00:00 2001 From: Samrudh Nelli <[email protected]> Date: Wed, 18 Feb 2026 11:42:51 +0530 Subject: [PATCH] [Clang] Add additional tests for constexpr initialization --- clang/test/AST/ByteCode/constexpr.c | 6 ++++++ clang/test/Sema/constexpr.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/clang/test/AST/ByteCode/constexpr.c b/clang/test/AST/ByteCode/constexpr.c index dfe3d667f27cc..b345d5e67aa43 100644 --- a/clang/test/AST/ByteCode/constexpr.c +++ b/clang/test/AST/ByteCode/constexpr.c @@ -313,6 +313,12 @@ constexpr int *V84 = 42; constexpr int *V85 = nullptr; constexpr int *V91 = 0.; // both-error@-1 {{initializing 'int *const' with an expression of incompatible type 'double'}} +constexpr int *V92 = 0.0f; +// both-error@-1 {{initializing 'int *const' with an expression of incompatible type 'float'}} +constexpr int *V93 = 0e0; +// both-error@-1 {{initializing 'int *const' with an expression of incompatible type 'double'}} +constexpr int *V94 = 0x0p0; +// both-error@-1 {{initializing 'int *const' with an expression of incompatible type 'double'}} // Check that constexpr variables should not be VLAs. void f6(const int P1) { 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@-1 {{initializing 'int *const' with an expression of incompatible type 'double'}} +constexpr int *V92 = 0.0f; +// expected-error@-1 {{initializing 'int *const' with an expression of incompatible type 'float'}} +constexpr int *V93 = 0e0; +// expected-error@-1 {{initializing 'int *const' with an expression of incompatible type 'double'}} +constexpr int *V94 = 0x0p0; +// expected-error@-1 {{initializing 'int *const' with an expression of incompatible type 'double'}} // Check that constexpr variables should not be VLAs. void f6(const int P1) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
