Temp HP is tracked separately (and removed first, in the case of taking damage), so you can ALWAYS gain temp HP.
The only restriction is that if you already have 5 temp HP, and something occurs to grant you say, 3 more, you don't gain them. They don't stack. You keep the 5. Now, if you had...