Commercial flights from the UK certainly do over fly Spanish airspace en-route AND
Spanish carriers ARE allowed in Gibraltar (Air Europe) have visited. The diversion point of choice IS
The issue i think you may be interested in is how flights enter the Gibraltar TMA.
This is where the political debacle is played out.
Flights over Spain continue under the Malaga control and are routed out into the Med as if going to Morocco !
Then then descend whilst out of controlled airspace and contact Gibraltar for approach clearance into the TMA.
This way they are Not passed directly from Spanish control to the UK military occupied forces on the ROCK.
Military flights are known to take many convoluted routes to the ROCK over the Atlantic and south of Cadiz.