Shiekh Al Islam Ibn Taymiyah gave a fatwa that it is not permissible to bury the dead inside the mosque, not a child, not an adult, nor a dignified person, or anyone else, because the mosques are not to resemble cemeteries. 

He said in another fatwa that it is not permissible to bury a dead person in a mosque. If the mosque was present before burial, then it must be restructured, either by leveling the grave or exhuming it if it was new. etc.

This is because when burial takes place in a mosque, it makes that part of the mosque outside of the area prescribed for obligatory prayers, its sunnahs, voluntary prayers, remembrance, and teaching of knowledge, and that is not permissible according to the Sharia. Having a grave inside the Mosque leads to people praying to this grave or near this grave, and many hadiths have narrated the evidence for banning this.

Sheikh Al-Islam Ibn Taymiyah said in his book “Iqtidau As-sirat al-Mustaqeem” page 158 :(The texts from the Prophet are many and frequently reported which prohibited praying at the graves, or making them mosques or building mosques on top of them, and from these Hadiths, the one narrated by Muslim on the authority of Abu Mirthad who said I heard the Prophet say: Do not sit on the graves, and do not pray on them)

Ibn Al Qayyim said: Imam Ahmad and others stated that if a person is buried in a mosque, he must be exhumed. 

Ibn Taymiyah said: A mosque and a grave cannot be combined, rather whichever comes after the other is prevented, and the preference is giving to the earlier among the two. [see Zadu al-Ma’ad].

Imam An-Nawawi said in his book (Al-Majmou’) :

The Shafi’ texts and the followers of his doctrine have agreed over the dislike of building a mosque on top of a grave, whether the deceased was known for his righteousness or something else, according to the general meaning of the hadiths.

Al Shafi’ and the followers of his doctrine also said: Prayer to grave is disliked, whether the deceased was a good person or someone else. Al-hafidh Abu Musa reported that Imam al-Za’farani- may Allah have mercy on him- said that burying a person in the mosque, makes that part of the mosque where he was buried no longer part of the mosque, so no obligatory prayers or sunnah can be prayed there. This leaves no room for doubt that it is not permissible according to the Sharia.