Constraints on models for TeV gamma rays from gamma-ray bursts