Uh, I guess, but how are you even accidently pressing undo? Wouldn't a confirmation just get in the way most of the time?
I don't know if that's the case for others, but I accidently press ctrl Z when I undo paint, an extra one which undo the whole duplication I previously placed. (which is extremely annoying when I didn't save)
In order so it doesn't get in the way, you could at least put only one warning, then pressing ctrl Z a second time, and it would be enough.