diff --git a/clang/lib/Sema/SemaFixItUtils.cpp b/clang/lib/Sema/SemaFixItUtils.cpp --- a/clang/lib/Sema/SemaFixItUtils.cpp +++ b/clang/lib/Sema/SemaFixItUtils.cpp @@ -132,6 +132,13 @@ if (!Expr->isLValue() || Expr->getObjectKind() != OK_Ordinary) return false; + // Do no take address of const pointer to get void* + const PointerType *FromPtrTy = dyn_cast(FromQTy); + const PointerType *ToPtrTy = dyn_cast(ToQTy); + if (FromPtrTy && FromPtrTy->getPointeeType().isConstQualified() && + ToPtrTy->isVoidPointerType()) + return false; + CanConvert = CompareTypes(S.Context.getPointerType(FromQTy), ToQTy, S, Begin, VK_PRValue); if (CanConvert) { diff --git a/clang/test/FixIt/fixit-function-call.cpp b/clang/test/FixIt/fixit-function-call.cpp --- a/clang/test/FixIt/fixit-function-call.cpp +++ b/clang/test/FixIt/fixit-function-call.cpp @@ -115,4 +115,16 @@ u(c); } +void accept_void(void*); + +void issue58958(const char* a) { +// CHECK: no matching function for call to 'accept_void' +// CHECK-NOT: take the address of the argument with & + accept_void(a); + char b; +// CHECK: no matching function for call to 'accept_void' +// CHECK: take the address of the argument with & + accept_void(b); +} + // CHECK: errors generated