Statistical inference for principal components of spiked covariance matrices