Just read a Register
The usual way to do this, safely and portably:

volatile uint16_t dummy = I2C1-&gt;SR1;
(void)dummy;


This usually works even on dysfunctional compilers. If the compiler still warns, you need to file a bug report to the compiler vendor.