File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,8 @@ CAST_OPERATION(ArrayToPointerDecay)
119
119
CAST_OPERATION(FunctionToPointerDecay)
120
120
121
121
// / CK_NullToPointer - Null pointer constant to pointer, ObjC
122
- // / pointer, or block pointer.
122
+ // / pointer, or block pointer. The result of this conversion can
123
+ // / still be a null pointer constant if it has type std::nullptr_t.
123
124
// / (void*) 0
124
125
// / void (^block)() = 0;
125
126
CAST_OPERATION(NullToPointer)
Original file line number Diff line number Diff line change @@ -850,12 +850,14 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) {
850
850
}
851
851
852
852
bool CodeGenTypes::isPointerZeroInitializable (QualType T) {
853
- assert ((T->isAnyPointerType () || T->isBlockPointerType ()) && " Invalid type" );
853
+ assert ((T->isAnyPointerType () || T->isBlockPointerType () ||
854
+ T->isNullPtrType ()) &&
855
+ " Invalid type" );
854
856
return isZeroInitializable (T);
855
857
}
856
858
857
859
bool CodeGenTypes::isZeroInitializable (QualType T) {
858
- if (T->getAs <PointerType>())
860
+ if (T->getAs <PointerType>() || T-> isNullPtrType () )
859
861
return Context.getTargetNullPointerValue (T) == 0 ;
860
862
861
863
if (const auto *AT = Context.getAsArrayType (T)) {
Original file line number Diff line number Diff line change @@ -70,3 +70,10 @@ namespace PR39528 {
70
70
void f (nullptr_t );
71
71
void g () { f (null); }
72
72
}
73
+
74
+ // CHECK-LABEL: define {{.*}}pr137276
75
+ // CHECK: {{^}} store i64 0, ptr %arr, align 8{{$}}
76
+ void pr137276 (nullptr_t np, int i) {
77
+ long arr[] = { long (np), i, 0 };
78
+ (void )arr;
79
+ }
You can’t perform that action at this time.
0 commit comments