Trent never says a justified, unbaptized goes to heaven. St Thomas THEORIZES they would go to purgatory. But the Church has never said. If you say otherwise, you’re delusional.
I wasn't talking about Trent.
St. Thomas says: No man obtains eternal life unless he be free from all guilt and debt of punishment. Now this plenary absolution is given when a man receives Baptism, or suffers martyrdom: for which reason is it stated that martyrdom "contains all the sacramental virtue of Baptism," i.e. as to the full deliverance from guilt and punishment. Suppose, therefore, a catechumen to have the desire for Baptism (else he could not be said to die in his good works, which cannot be without "faith that worketh by charity"), such a one, were he to die, would not forthwith come to eternal life, but would suffer punishment for his past sins, "but he himself shall be saved, yet so as by fire" as is stated 1 Corinthians 3:15.
After purgatory the catechumen goes to heaven eventually according to a Thomistic understanding.
As for some Church teachings on the matter:
In his decree about a Jew who, in danger of death, attempted to baptize himself, since those around his death bed refused to baptize him, Innocent III decrees:
We respond that, since there should be a distinction between the one baptizing and the one baptized, as is clearly gathered from the words of the Lord, when He says to the Apostles: "Go, baptize all nations in the name etc.," the Jew mentioned must be baptized again by another, that it may be shown that he who is baptized is one person, and he who baptizes another ... If, however, such a one had died immєdιαtely, he would have rushed to his heavenly home without delay because of the faith of the sacrament, although not because of the sacrament of faith (Dz. 413, emphasis added).
Pope Innocent II taught the same with regard to a priest, when after his death it was found that he had not been baptized. He writes:
Read (brother) in the eighth book of Augustine’s City of God where, among other things it is written, "Baptism is ministered invisibly to one whom not contempt of religion but death excludes." Read again the book also of the blessed Ambrose concerning the death of Valentinian where he says the same thing. Therefore, to questions concerning the dead, you should hold the opinions of the learned Fathers, and in your church you should join in prayers and you should have sacrifices offered to God for the priest mentioned (Innocent II, Letter Apostolicam Sedem, Dz. 388, emphasis added)