(a) Where deductions are allowable under
section 404(a) (1) or (2) on account of contributions under a pension or annuity plan and deductions are also allowable under
section 404(a)(3) for the same taxable year on account of contributions to a profit-sharing or stock bonus trust, the total deductions under these sections are subject to the provisions of
section 404(a)(7) unless no employee who is a beneficiary under the trusts or plans for which deductions are allowable under
section 404(a) (1) or (2) is also a beneficiary under the trusts for which deductions are allowable under
section 404(a)(3). The provisions of
section 404(a)(7) apply only to deductions for overlapping trusts or plans,
i.e., for all trusts or plans for which deductions are allowable under
section 404(a) (1), (2), or (3) except (1) any trust or plan for which deductions are allowable under
section 404(a) (1) or (2) and which does not cover any employee who is also covered under a trust for which deductions are allowable under
section 404(a) (3), and (2) any trust for which deductions are allowable under
section 404(a)(3) and which does not cover any employee who is also covered under a trust or plan for which deductions are allowable under
section 404(a) (1) or (2). The limitations under
section 404(a)(7) for any taxable year of the employer are based on the compensation otherwise paid or accrued during the year by the employer to all employees who, in such year, are beneficiaries of the funds accumulated under one or more of the overlapping trusts or plans. For purposes of the preceding sentence, if the taxable year of the employer with respect to which the limitation is being computed ends with or within a taxable year of any of the overlapping trusts or plans during which any such trust is not exempt under
section 501(a) or, in the case of a plan, during which it does not meet the requirements of
section 404(a)(2), or if such taxable year of the employer ends after any such trust or plan has terminated, then, with respect to such trust or plan, those employees, and only those employees, who, at any time during the one-year period ending on the last day of the last calendar month during which the trust was exempt under
section 501(a), or the plan met the requirements of
section 404(a)(2), were beneficiaries of the funds accumulated under such trust or plan shall be considered the beneficiaries of such trust or plan in the taxable year of the employer with respect to which the limitation is being computed. For purposes of this paragraph, “compensation otherwise paid or accrued” means all of the compensation paid or accrued except that for which a deduction is allowable under a plan that qualifies under
section 401(a), including a plan that qualifies under
section 404(a)(2).