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
@@ -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
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
@@ -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
@@ -3115,11 +3115,24 @@ void CastOperation::CheckCStyleCast() {
Self.CurFPFeatureOverrides());
}
}
- if (DestType->isNullPtrType() && !SrcType->isNullPtrType()) {
-Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)
@@ -3115,11 +3115,24 @@ void CastOperation::CheckCStyleCast() {
Self.CurFPFeatureOverrides());
}
}
- if (DestType->isNullPtrType() && !SrcType->isNullPtrType()) {
-Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)
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