Probing stellar evolution with S stars and Gaia