SHTF. One gun. An unrealistic and contrived scenario. But if this actually came to be, my first thinking point would be "where am I?" If I am rural, on property with a lot of acres, it would be a rifle. If I am urban/suburban, it would be a handgun. Because rural, you're probably more concerned (and able) to hunt your own food. A rifle facilitates that. Also, you may see incoming human threats from farther away. A rifle facilitates taking care of that problem. Urban/suburban, you're really not going to be hunting food much, despite what you may dream of doing. More likely you are going to be defending yourself against human threats. Up close and surprise human threats. A handgun facilitates your self defense in that type of scenario.
Talking urban/suburban handgun first, I would want something that uses commonly available ammo. SHTF, not everybody has a lifetime supply of ammo. The prepared might, but most people aren't THAT prepared. So most people will have to scrounge ammo after a while. If I had to guess, the calibers you are most likely to find in any random house are .22LR and 9mm. I would go for 9mm as my choice, since it is the better of the two for defense. So I've already decided 9mm handgun, and a semi-auto (there are 9mm revolvers, but they are rare and serve a limited purpose IMHO). Next question is size of the handgun. Small for concealment, large for capacity. SHTF - I don't think concealability would be a huge concern. So my decision is almost made - a full size 9mm semi-auto handgun. But which specific one? I think this is the least important question. Stay with a well established and large manufacturer. Glock, Sig, S&W, etc. For the same reason I chose 9mm in the first place - what are you more likely to find when scrounging the random house (say, you want to acquire a spare magazine). So, for urban/suburban my choice would be "full size Glock 9mm semi-auto". This, despite Glocks being about my least personal favorite handguns. But they are everywhere, thus a good choice for an "only one gun" solution.
Moving to rural, I would want a rifle. But I am personally surburban so I can't claim any expertise in the rural setting. I can still present my thought processes, but they may be flawed. The first thing I'd look at is the caliber. I want something that can take medium and large sized game ... and humans. And I want a common caliber as well (for scroungability). On the low end, I'd start with .223. Not really "large game" capable. But it's everywhere. After that, well, I'm starting to falter. .308 maybe? If you live among lots of hunters, maybe .30-30 or .243? I really don't know. So, as much as I consider the .223 a "weak" cartridge (despite what the media portrays it as), I would probably have to give that very serious consideration. If I were expecting to do more large game hunting, the .308 would be there as well. More leaning towards self defense? Hard to beat 7.62x39 in an AK. Yes, the SKS shoots this cartridge as well, but I dare say you'll probably find more AK's laying around (for scroungeability) than SKS's. Push comes to shove, I'd probably choose an AR15. Tons of scroungability there - the rifle itself, spare parts, accessories, ammo.
After all this, I am quite dismayed to find that I have chosen my arguably two least favorite guns. One for the urban/suburban environment, and one for the rural environment. It's still "only one gun" because you can only live in one of these two environments at a time, so choose based on the environment. The Glock and the AR15.
Given the artificially severe limitation of "only one gun", then this makes the most sense to me. If we were to open this up to "only TWO guns", then I doubt either the Glock or the AR15 would make it onto my list. At the very least, they would have some serious competition to deal with. But for "only one gun" in a no-resupply situation, it's hard NOT to go with "use the gun that EVERYBODY ELSE has". As much as I love my HK P30, I could probably search my entire town and only find one or two more of those. So it would be a bad choice for a single-firearm SHTF weapon. I wouldn't do any better searching for another personal favorite - the Walther PPQ. Especially since mine is the original trigger-guard-paddle-mag-release version and not the much more common M2 version with the push button mag release (these two guns use different magazines). I would love to have either of these guns post-SHTF ... but not as my "only gun". I would yield to my brain and not my heart, and just go with the boring old Glock.