Anomaly-free supergravity theories remain anomaly-free after dimensional reduction