It shall be the duty of the court, of its own motion and without waiting for objection, to advise a witness at the appropriate time of his right to refuse to answer any question requiring the disclosure of any privileged communication or requiring or tending to require the witness to give testimony which might incriminate him, but the last clause shall not apply to a defendant in a criminal case who takes the stand to testify in his own behalf.
SDCL 19-2-8