For purposes of part II of subchapter F of chapter 1 (other than section 508(a), (b), and (c)) and for purposes of this chapter, a trust which is not exempt from taxation under section 501(a), all of the unexpired interests in which are devoted to one or more of the purposes described in section 170(c)(2)(B), and for which a deduction was allowed under section 170, 545(b)(2), 642(c), 2055, 2106(a)(2), or 2522 (or the corresponding provisions of prior law), shall be treated as an organization described in section 501(c)(3). For purposes of section 509(a)(3)(A), such a trust shall be treated as if organized on the day on which it first becomes subject to this paragraph.
For purposes of paragraph (2)(B), a trust with respect to which amounts are segregated shall separately account for the various income, deduction, and other items properly attributable to each of such segregated amounts.
The Secretary shall prescribe such regulations as may be necessary to carry out the purposes of this section.
The provisions of section 507(a) shall not apply to a trust which is described in subsection (a)(2) by reason of a distribution of qualified employer securities (as defined in section 664(g)(4)) to an employee stock ownership plan (as defined in section 4975(e)(7)) in a qualified gratuitous transfer (as defined by section 664(g)).