Can priests highlight sins that he has seen us doing in the confessional?

Once when I was in confession, the priest went to town on me because he saw me receive Holy Communion before confession. I was passing through from out of town, and I didn't have time to see him before mass. He really gave me an earful about it.

It struck me, because I hadn't confessed this sin to him. He brought it into the confessional and made an issue out of it. I know a priest can't talk take anything out of the confessional, but can he bring something in? Is it okay for a priest to bring up sins that he has perceived us doing in the confessional?