Long term effect? On a well maintain weapon I'd say no. I've got a Remington 870 that saw mostly trunk duty for 25 years in outside temperatures that ranged from 113 degrees to -20 degrees. God only knows what the temperature was inside the black trunk on that 113 degree day. I'd still bet my life on that 870.
Short term effect? Yes. Metal and polymer will expand and contract with temperature variations. If you go from inside to outside or out to in, moisture condensation will occur.
The expansion and contraction is hard on optics and mounts. screws will loosen up if not held in by an anaerobic adhesive such as Loctite. Glass and metal expand and contract at different rates, and this will make the difference in cheap and premium optics very apparent. Also a cheap optic with a lighted reticule may not work properly. I've used my Aimpoint when it was -36 one night.
Lubricants need to be addressed. During a long, hot summer in a vehicle, lubricants will evaporate. Some such as WD 40 will leave a god awful residue. I actually saw the piston on a Mini 14 'glued' to the gas block by the residue left from an evaporated lubricant.
During extremely cold weather cheap lubricants gel. This will effect the function of all the moving parts particularly the firing pin. It can actually freeze in place. I use CLP, but I'm thinking of changing to a synthetic engine oil.
Ammunition is also effected by temperature variation, much more so than the firearm.