Stronger-than-expected second-quarter results in the U.S. and rising analyst earnings forecasts emerged as a fresh catalyst for stocks.