(725 ILCS 5/115-2) (from Ch. 38, par. 115-2)
    Sec. 115-2. Pleas of Guilty and guilty but mentally ill. (a) Before or during trial a plea of guilty may be accepted when:
    (1) The defendant enters a plea of guilty in open court;
    (2) The court has informed the defendant of the consequences of his plea and of the maximum penalty provided by law which may be imposed upon acceptance of such plea.
     Upon acceptance of a plea of guilty the court shall determine the factual basis for the plea.
    (b) Before or during trial a plea of guilty but mentally ill may be accepted by the court when:
    (1) the defendant has undergone an examination by a clinical psychologist or psychiatrist and has waived his right to trial; and
    (2) the judge has examined the psychiatric or psychological report or reports; and
    (3) the judge has held a hearing, at which either party may present evidence, on the issue of the defendant's mental health and, at the conclusion of such hearing, is satisfied that there is a factual basis that the defendant was mentally ill at the time of the offense to which the plea is entered.
(Source: P.A. 82-553.)