It's very bad practice to leave a guitar in a hot car for any amount of time, but the longer the time, the worse off your instrument will be, especially when the weather is hot. Five hours is absolutely too much.
When it's 35C (95F) outside, it's possible that your car is getting hot enough to melt hide glue, which is frequently used by luthiers and melts around 60 C (140F). Any part of your guitar that's held together with hide glue can loosen or come apart when the glue melts.
You are also risking cracking the wood because while the outside air is 80% humidity, the air in the overheated car is far drier, so your instrument is going through drastic changes in humidity, the perfect recipe to crack and warp it. Damage from this can be cumulative, with tiny invisible cracks forming, then eventually expanding as the instrument is further abused.
It's less dangerous in the cold, but the instrument is still subject to changing humidity as the car heats up.
A cheap plywood instrument mass produced with synthetic adhesives is less likely to be damaged, although it still isn't completely safe.
If you must leave the instrument in the car, park in the shade and leave the windows cracked. Put the instrument out of the sun, either in the trunk or under a blanket if you don't have a trunk. But bringing it with you is a much safer idea.