I don't want to be a naysayer, but if you're going to run that cord you have to have 30A circuit protection before the cord. Basically, everything downstream of the 40A breaker has to be capable of carrying 40A safely until it hits 30A circuit protection. Imagine if something goes wonky and there is a short before your 30A protection. Now your cord is carrying 40A, because that's what the breaker upstream is letting it pull (assuming things are really wrong and that breaker hasn't tripped yet). Since the cord is only rated to 30A, but it's getting fed 40A, it could heat up, causing the insulation to melt and starting a fire or energizing something it touches if the insulation burns through. Obviously this is a worst case scenario, but it's one that you don't want to experience.
To be safe, either replace the breaker with a 30A (talk to your landlord first) or run a 40A cord to your panel and integrate the GFCI elsewhere.