A cup of wine over which one recites a Beracha – such as the cup used for Kiddush or for Birkat Ha’mazon – must not be a "Kos Pagum" ("defective cup"), which means that it must not have been drunk from. If somebody had a full cup of wine at the table during a meal, and he took a sip of wine from that cup, that cup may not then be used for Birkat Ha’mazon.
One may, however, "repair" a "Kos Pagum" by pouring wine or water into the cup. Even pouring just a single drop into the cup renders it suitable for use for Birkat Ha’mazon. However, the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909) writes that one must ensure that the cup from which one pours into the "Kos Pagum" is not itself a "Kos Pagum." Thus, for example, one may not "repair" a "Kos Pagum" by pouring water or wine from a cup from which one had drunk during the meal. He must use fresh water, such as from the bottle on the table.
One may "repair" the cup also with other beverages, besides wine and water, as long as this does not ruin the wine. Another option is to put an ice cube into the cup of wine. Some authorities even allow "repairing" the cup by placing a piece of bread in the cup.
The Poskim also mention a different solution – pouring the wine from the "Kos Pagum" into a smaller cup. As long as there is a "Rebi’it" of wine in the second cup, it may then be used for Kiddush or for Birkat Ha’mazon.
There is a view among the Poskim that one may not "repair" a "Kos Pagum" on Shabbat, but Halacha does not follow this view. Rav Shlomo Zalman Auerbach (Israel, 1910-1995) explained that those who held this opinion followed the view that a "Kos Pagum" cannot be repaired by adding just one drop, and one needs to pour enough wine into the cup that the majority of the cup consists of new wine. According to this view, the way a "Kos Pagum" is "repaired" is through the Halachic concept of "Bittul" – whereby the minority of a mixture is negated by the majority. As "Bittul" is forbidden on Shabbat – since it resembles fixing something – this view would not permit "repairing" a "Kos Pagum" on Shabbat. But as Halacha follows the view that it suffices to add just one drop to the cup, this is entirely permissible on Shabbat.
It should be noted that if, for whatever reason, one has access only to a "Kos Pagum," and does not have the possibility to "repair" it, the cup may nevertheless be used for the Beracha. The Halacha disqualifying such a cup applies only on the level of "Le’chatehila" (the optimal level of observance), and thus when no other options are available, such a cup may be used.
Summary: A cup from which one has drunk may not be used for Kiddush or for Birkat Ha’mazon, unless no other options are available. Such a cup may be "repaired" and made suitable for Kiddush or Birkat Ha’mazon by pouring even a drop of wine or water into the cup, though the new water or wine must be poured from a cup which itself has not been drunk from. One may also use a different beverage, as long as this does not ruin the wine. Other options are putting an ice cube or piece of bread into the cup, or to simply pour the wine out of the cup into a smaller cup (as long as there is a "Rebi’it" of wine). All these may be done even on Shabbat.