diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index ef9095291cdf..b54264b5054f 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1586,7 +1586,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (const auto *RefTy = RetTy->getAs()) { QualType PTy = RefTy->getPointeeType(); - if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) + if (getCXXABI().isTypeInfoCalculable(PTy) && PTy->isConstantSizeType()) RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy) .getQuantity()); else if (getContext().getTargetAddressSpace(PTy) == 0) @@ -1698,7 +1698,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (const auto *RefTy = ParamType->getAs()) { QualType PTy = RefTy->getPointeeType(); - if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) + if (getCXXABI().isTypeInfoCalculable(PTy) && PTy->isConstantSizeType()) Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy) .getQuantity()); else if (getContext().getTargetAddressSpace(PTy) == 0) diff --git a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp index 27a2a5fc9c16..25d7c7702da0 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp @@ -745,4 +745,10 @@ void foo_fun() { // CHECK: store i8* bitcast (void (%class.CA*)* @"\01?OnHelp@CA@@QAEXXZ" to i8*), i8** f func = (f)&CA::OnHelp; } +namespace PR24703 { +struct S; + +void f(int S::*&p) {} +// CHECK-LABEL: define void @"\01?f@PR24703@@YAXAAPQS@1@H@Z"( +}