As I posted it depends on the machine and what the User Guide states for it.
+But does that mean anything that isn't specifically allowed in the manual and/or warranty is not allowed?+
My take on that would be; Yes, Apple reserve the right to void a warranty if anything they don't like has been done to a piece of hardware. (I've seen/heard them void for all sorts of (pretty feeble) reasons, for example "smoke discolouration" due to the user being a cigarette smoker or a minor dint in the casing)
+That's the written Apple policy I'd like to see+
Apple state:
4. What kind of activities will void my warranty?
Apple’s One-Year Limited Warranty for MacBook Pro excludes coverage for damage resulting from a number of events, including accident, liquid spill or submersion, *unauthorized service and unauthorized modifications*. If damage is outside the scope of warranty coverage, service may be available through a local AASP or an Apple retail store, but all service charges will be your responsibility. In such an event, you will be asked to approve the estimated charges and accept the terms and conditions for service before authorizing the repair. If the repair is performed at an Apple retail store Apple's Repair Terms and Conditions will govern service. Repair service for a MacBook Pro that has experienced catastrophic damage, for example extensive liquid damage or a severe impact that results in the product being disassembled into multiple pieces, is generally not available and not eligible for service.
So, in a nutshell, if the user guide says it's OK to upgrade the RAM and hard drive that's an authorised modification and, provided the user doesn't break anything, the warranty is sound. Doing anything else to it does enable the termination of warranty.