It wasnarrated from 'Amr bin Shu'aib, from his father, from hisgrandfather that the Messenger of Allah (ﷺ) said:
"Whoevercommitsadultery with a slave woman or a free woman, his child isillegitimate, and he cannot inherit from him or be inherited from(i.e., this child cannot inherit from him)." (ES)
English reference (ES): Vol. 4, Book 23, Hadith 2745 (ES)
Arabic reference (ES): Book 23, Hadith 2850 (ES)