Gasquet will face Sock after beating Shapovalov in ParisRichard Gasquet of France hits a return shot to Juan Martin del Potro of Argentina during their men's singles match in the Shanghai Masters tennis tournament in Shanghai, China, Wednesday, Oct. 10, 2018. (AP Photo/Andy Wong)
All three still advanced at the Shanghai Masters on Wednesday.
Federer, the defending champion, beat Daniil Medvedev 6-4, 4-6, 6-4 in the second round despite being broken late in the second set.
''I was able to mix it up. Really also took some chances, serve and volley, second serve,'' the top-seeded Federer said. ''In the third set I really started to figure it out, as well, how aggressive or how tactical I wanted to make the match. And by trying everything, I found a solution at the end, which was a great feeling to have.''
The third-seeded del Potro trailed in the first set and in the tiebreaker but rebounded both times to beat Richard Gasquet 7-5, 7-6 (7).
''It wasn't easy to play for me today,'' said del Potro, who reached the China Open final last week. ''I did what I can. I didn't run too much. But I think I played with all my strength in the important moment of the match.
''I would love to feel better,'' he added. ''I have been talking with the doctors every day.''
The fourth-seeded Zverev was also struggling with a cold, but he beat Nicoloz Basilashvili 7-5, 6-4.
Basilashvili arrived in Shanghai after beating del Potro in Beijing to win his second career title.
''I played an opponent who has a lot of confidence,'' Zverev said. ''Obviously he's playing the best tennis of his life, winning in Beijing, and obviously he had a very good match yesterday, as well.
''He knows how to play, definitely. Probably the hardest-hitting player I have ever played against.''
Zverev is playing in Shanghai without his coach, Ivan Lendl, who was in Beijing last week. Lendl flew back to the United States to have wrist surgery, which Zverev said was caused by playing too much golf. Lendl is due to return to the tour before the end of the season.
Earlier, 10th-seeded Stefanos Tsitsipas beat Karen Khachanov 6-4, 7-6 (8) - the second straight year that the Greek player has defeated Khachanov in the second round in Shanghai.
''We played here last year and it was the place I got my first ATP win,'' Tsitsipas said. ''I knew today was going to be a different match. I played every single point as if there was no tomorrow.''
More AP tennis coverage: https://apnews.com/tag/apf-Tennis and https://twitter.com/AP-Sports