St. Thomas Aquinas holds that God can do anything except whatever implies a contradiction.
Treating "Whether God is omnipotent?," he writes:
[T]his phrase, "God can do all things," is rightly understood to mean that God can do all things that are possible; and for this reason He is said to be omnipotent.
[N]othing is opposed to the idea of being except non-being. Therefore, that which implies being and non-being at the same time is repugnant to the idea of an absolutely possible thing, within the scope of the divine omnipotence. For such cannot come under the divine omnipotence, not because of any defect in the power of God, but because it has not the nature of a feasible or possible thing. Therefore, everything that does not imply a contradiction in terms, is numbered amongst those possible things, in respect of which God is called omnipotent: whereas whatever implies contradiction does not come within the scope of divine omnipotence, because it cannot have the aspect of possibility. Hence it is better to say that such things cannot be done, than that God cannot do them.
Essentially, God cannot do "whatever implies contradiction" not because God lacks omnipotence but because a contradiction, itself, is no thing; it lacks being; it's unintelligible.