The Sun is actually a THIRD generation star. What I mean by this, is that there are chemical elements in the Sun that were made inside another star, but that star itself can only have made those elements because it had material in it that must also have been made inside previous, second generation, stars. Eventually we get back to the first generation stars, born out of primordial gas from the big-bang bang that contained almost no heavy elements (those beyond helium) at all.
So, before the Sun, there must have existed a star - probably an intermediate mass star - which evolved to become a giant, made barium in its interior, then lost its envelope through a massive wind into the interstellar medium, and that material was incorporated into the protosun. Such stars (between, say, 2 and 10 solar masses) would have much shorter lifetimes than the Sun$^2$, so plenty of time for them to live and die before the Sun was born.
But wait a minute! That previous star must have already had iron-peak elements in its interior to act as a "seed" for the s-process production of barium. These were not and could not be made inside that star. They must have been made in a previous star, probably a massive star, that burned through all the nuclear fusion stages before exploding as a supernova, casting heavy elements, including iron-peak elements, into the interstellar medium. This previous star could also have had its own (metal-rich) ancestors, but ultimately as we go back in time we reach a point where the previous star was a first generation star, made from primordial H/He gas, with almost no heavy elements. These first generation (a.k.a. population III stars, just to be confusing), were probably very massive and short lived - a few million years. They would be born when the universe was a few hundred million years old and we can see no examples of them in our Galaxy today.
- First generation - made from primordial big bang material.
- Second generation - a star made only from the detritus of dying first generation stars, enriched in heavy elements;elements but lacking in primary s-process elements.
- Third generation - a star made from material already enriched in heavy elements and including elements that are produced in the s-process inside previous second (or third) generation stars.
However, these are vast under-estimatesunderestimates. Mixing in the interstellar medium is reasonably effective. The material spewed out from supernovae and stellar winds 5-12 billion years ago has had plenty of time to mix throughout the Galaxy before the Sun's birth. Turbulence and shear instabilities, driven by the winds ansand supernovae from massive stars, should distribute material on galactic length-length scales in a billion years or less (Roy & Kunth 1995; de Avillez & Mac Low 2003), though local inhomogeneities associated with nearby recent events can persist over $10^{8}$ years. If this is the case, then the Sun is the product of the $\sim$ billion stars that died before it was born.
$^1$ The rest are produced by the s-process in intermediate mass AGB stars; through nova events on white dwarfs; or perhaps, in the case of the heavier elements, through the collision of neutron stars (see this Physics SE question).