This is more or less what happened with the house of Beaufort in England, John of Gaunt (one of the sons of Edward III, founder of the House of Lancaster and the father of future king Henry IV) had a son John with his mistress Katherine Swynford. As he was born out of wedlock he was considered a bastard. However when Gaunt later married Swynford John was legitimized not as a Plantagenet but rather with the surname of Beaufort. He and his descendants were also barred from the line of succession to the English throne. The Beauforts were to gain immense power and prestige as the result of their Lancastrian half-brother Henry IV's accession to the throne and became one of the 5 great families of mid-15th century England and became serious players in the War of the Roses but were wiped out in the male line due to Battlefield defeats. Through the female line however Margaret Beaufort was to be the mother of Henry Tudor and hence the Beaufort blood ran in the veins of the Tudors and all subsequent British monarchs.
In Catholic canon law, a child born to parents who later married was not a bastard. He would be the heir. (Summa Theologica) The old Catholic Encyclopedia says that that had been in Roman law, but I have no other data on that.
In the later feudal and land inheritance laws of England, that did not apply. The child was a bastard from birth and would be forever.
/u/larkspurblossom here has a couple of examples, but note that they're early. Bastards were treated much better earlier on, but by the 1100s attitudes against them were hardening. William the Bastard had no big problem. In the mid-1100s anarchy between Matilda and Stephen, by all accounts her half brother Robert (first Earl of Gloucester) was a really great guy, and England would have prospered under his reign ... but he was a bastard and by that time that was a disqualification.
Is there a specific country or era that you're asking about?
I apologize for the vague question. I wasn't really focusing on any particular region or time period, but for the sake of the question, let's say 10th-13th century France. I was hoping to know what may have happened to a child born into this situation, if say, he was the first and only child to both parents. Would he be looked down upon? Would he be considered a suitable heir? Thanks for any replies.