Compact steep-spectrum sources as the parent population of flat-spectrum radio-loud narrow-line Seyfert 1 galaxies