[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/133742 C23 allows a cast of a null pointer constant to nullptr_t. e.g., (nullptr_t)0 or (nullptr_t)(void *)0. Fixes #133644 >From 5ad66ec7a9ea76a080ee34ddf0d68a19dbb9dec6 Mon Sep 17 00:00:00 2001 From: Aaron Bal

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -93,6 +91,9 @@ void test() { (int *)null_val;// ok (int *)nullptr; // ok (nullptr_t)nullptr; // ok + (nullptr_t)0; // ok AaronBallman wrote: I added that test coverage in fb9deab74e5dc9a9227732fcd95c1aadacf86d44, thanks for the suggest

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-04-02 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/133742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-03-31 Thread via cfe-commits
@@ -93,6 +91,9 @@ void test() { (int *)null_val;// ok (int *)nullptr; // ok (nullptr_t)nullptr; // ok + (nullptr_t)0; // ok + (nullptr_t)(void *)0; // ok + (nullptr_t)null_val; // ok Sirraide wrote: What about `(nullptr_t)__null` https

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-03-31 Thread James Y Knight via cfe-commits
@@ -3115,11 +3115,24 @@ void CastOperation::CheckCStyleCast() { Self.CurFPFeatureOverrides()); } } - if (DestType->isNullPtrType() && !SrcType->isNullPtrType()) { -Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-03-31 Thread James Y Knight via cfe-commits
@@ -3115,11 +3115,24 @@ void CastOperation::CheckCStyleCast() { Self.CurFPFeatureOverrides()); } } - if (DestType->isNullPtrType() && !SrcType->isNullPtrType()) { -Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-03-31 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes C23 allows a cast of a null pointer constant to nullptr_t. e.g., (nullptr_t)0 or (nullptr_t)(void *)0. Fixes #133644 --- Full diff: https://github.com/llvm/llvm-project/pull/133742.diff 3 Files Affe