If one dreams on Shabbath that a Jewish person is going to die or get ill, one should pray for him, give charity on his account and fast because of the dream. Alternatively, he should mention indirectly to the person he dreamt about, that he is in need of mercy from Heaven and should make Teshubah (repent).
What he must not do, however, is tell his friend specifically, that he dreamt that he would die. The reason is that we are concerned that the friend may take it very much to heart and the fright might cause him to die.
There is an opinion that this only applies if one had this dream three times. There is also the opinion that, nowadays, we do not know what is considered to be a bad dream. Nevertheless, the Aharonim say that when one has what we consider to be a bad dream, it is preferable to pray on Shabbath and read Tehillim on Shabbath, rather than fast, since we are not expert in interpreting dreams. Additionally, on Sunday, one should give charity.
(See Derekh HaTorah, 7:75. 76)
Bad dreams on Shabbath, fasting or not