If the thing bequeathed belonged to the legatee or devisee at the time of the execution of the will, the legacy or devise shall be without effect, even though it may have subsequently alienated by him.
If the legatee or devisee acquires it gratuitously after such time, he can claim nothing by virtue of the legacy or devise; but if it has been acquired by onerous title he can demand reimbursement from the heir or the estate. (878a)