The wife of a Kohen:
It is permitted for the pregnant wife of a Kohen to enter a cemetery. Nonetheless, some Poskim rule it is proper to be stringent not to do so [even on a Yartzite or by Kivrei Tzaddikim]. This especially applies if she knows that the gender of the child is male or she is at the end of her term and is ready for birth. Nevertheless, even in such a case, most Poskim rule it is allowed from the letter of the law.
 Shach Y.D. 371/1; Rokeiach 366; M”A 343/2; Radbaz 200; Kneses Hagedola [brought in Birkeiy Yosef 343/4-there he writes it’s a Minhag Borus to be stringent] Derech Hachaim; Chochmas Adam 160/1; Kitzur SHU”A 202/15; M”B 343/3; See Pischeiy Teshuvah 371/1; Gilyon Maharsha 371; Darkei Chesed p. 208
The reason: As there is a Safek Sfeka; perhaps the fetus is a female and perhaps it will be a stillborn. [Shach ibid; Rokeiach ibid] Alternatively a fetus cannot receive impurity as it is considered within a Beis Hablia. [M”A ibid; Radbaz 200, brought in Shaareiy Teshuvah 371/1; See there that even the Rokeiach agrees to this.] Others however argue that a fetus is considered part of the mother [Yerech Imo] and hence can contract impurity even during pregnancy. [Birkeiy Yosef 343/1]
 Birkeiy Yosef 343/4; Kaf Hachaim 343/4; Minchas Yitzchak 1042
The reason: As if in truth the child is a boy he contracts impurity. [This is proven from fact the Rokeiach only allows it due to Safek Sfeika. See previous footnote for the dispute regarding Beis Hablia] Hence, it is proper to initially avoid doing so. [ibid]
 As then there is no longer a Sfek Sfeka according to the Rokeiach [as learns Birkeiy Yosef ibid], although according to many Poskim this would still remain permitted being that the fetus is considered within a Beis Hablia, as brought from M”A ibid and Radbaz ibid and so is evident from other Poskim mentioned in next footnote] See Even Yisrael 8/77 that deals with this question in regards to giving birth in a hospital that is not careful about Tumas Meis. He concludes there that ultrasounds are not 100% accurate, and that it is for the needs of a Yoledes who is in Sakana and hence she may choose to go to whatever hospital she wishes. Nevertheless, she is not initially to take an ultrasound and hence remove the Sfek Sfeka. This is all with regards to which hospital to give birth and does not relate to a pregnant woman entering a Beis Hakevaros if she knows the child is male. It is understood that in such a case there are more Poskim who rule stringently.
 Sheilas Yaavetz 2/174 forbids in such a case [as the child may be born]; opinion in Darkei Chesed p. 208; Most Poskim however permit even in such a case, as the Sfek Sfeika still remains. [M”B 343/3; Radbaz ibid brought in Pischeiy Teshuvah ibid, that this was the original case of allowance written by the Rokeaich; Betzeil Hachochmah 3/105]
 See previous footnotes; and so ruled to me Harav Asher Lemel Cohen that practically it is not accustomed to be stringent.