Assuming that the Sacramemt is valid, meaning that the person going to the priest is a baptized Catholic and is seeking repentance then the priest is bound by the seal of Confession. This means that they are not to reveal the sins confessed under any circumstances as God is the ultimate judge and arbiter.
In most cases, a priest will be bound by the seal of confession anyway because they will
Often not know if the person is a Cathoic or not, etc. Again, because God is the final judge and is the One actually forgiving the sin, the priest is acting in good faith so the added sacrilege of partaking, especially willing of a Sacrament for, which one is not supposed to receive, weighs on the person confessing. So if you go to confession and willfully leave something out then not only did you not receive absolution you comitted another mortal sin.
The Seal of Confession is there so that the person confessing is able to come before a representiive of Christ and humbly seek repentance with at least partial contrition (meaning that the person is at least seeking to be right with God because they fear hell).