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)
119119CAST_OPERATION(FunctionToPointerDecay)
120120
121121// / 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.
123124// / (void*) 0
124125// / void (^block)() = 0;
125126CAST_OPERATION(NullToPointer)
Original file line number Diff line number Diff line change @@ -850,12 +850,14 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) {
850850}
851851
852852bool CodeGenTypes::isPointerZeroInitializable (QualType T) {
853- assert ((T->isAnyPointerType () || T->isBlockPointerType ()) && " Invalid type" );
853+ assert ((T->isAnyPointerType () || T->isBlockPointerType () ||
854+ T->isNullPtrType ()) &&
855+ " Invalid type" );
854856 return isZeroInitializable (T);
855857}
856858
857859bool CodeGenTypes::isZeroInitializable (QualType T) {
858- if (T->getAs <PointerType>())
860+ if (T->getAs <PointerType>() || T-> isNullPtrType () )
859861 return Context.getTargetNullPointerValue (T) == 0 ;
860862
861863 if (const auto *AT = Context.getAsArrayType (T)) {
Original file line number Diff line number Diff line change @@ -70,3 +70,10 @@ namespace PR39528 {
7070 void f (nullptr_t );
7171 void g () { f (null); }
7272}
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