In stm32f0xx_hal_flash.c line 319: /* Check if there are still pages to erase */
if(pFlash.DataRemaining != 0U)
{
addresstmp = pFlash.Address;
/*Indicate user which sector has been erased */
HAL_FLASH_...
This is indeed true. It turned out that I was locking the flash memory in the interrupt handler, and after that these bits cannot be set. That's why these lines did not work for me. Thank you.