Section 23B. A provision in an instrument relating to real property which purports to forbid or restrict the conveyance, encumbrance, occupancy, or lease thereof to individuals of a specified race, color, religion, national origin or sex shall be void. Any condition, restriction or prohibition, including a right of entry or a possibility of reverter, which directly or indirectly limits the use for occupancy of real property on the basis of race, color, religion, national origin or sex shall be void, excepting a limitation on the basis of religion on the use of real property held by a religious or denominational institution or organization or by an organization operated for charitable or educational purposes which is operated, supervised or controlled by or in connection with a religious organization.