Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions clang/lib/CodeGen/CodeGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,14 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) {
}

bool CodeGenTypes::isPointerZeroInitializable(QualType T) {
assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type");
assert((T->isAnyPointerType() || T->isBlockPointerType() ||
T->isNullPtrType()) &&
"Invalid type");
return isZeroInitializable(T);
}

bool CodeGenTypes::isZeroInitializable(QualType T) {
if (T->getAs<PointerType>())
if (T->getAs<PointerType>() || T->isNullPtrType())
return Context.getTargetNullPointerValue(T) == 0;

if (const auto *AT = Context.getAsArrayType(T)) {
Expand Down
13 changes: 13 additions & 0 deletions clang/test/CodeGenCXX/pr137276.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s

using ulong = unsigned long;
template <class... Ts>
void g(Ts... args) {
ulong arr[3] = {ulong(args)...};
(void)arr;
}
extern void f() {
g(nullptr, 17);
}

// CHECK: {{^}} store i64 0, ptr %arr, align 8{{$}}
Loading