The Council shall ... adopt such measures in the field of social security as are necessary to provide freedom of movement for workers; to this end, it shall make arrangements to secure for migrant workers and their dependants: (a) aggregation for the purpose of acquiring and retaining the right to benefit and of calculating the amount of benefit, of all periods taken into account under the laws of the several countries; (b) payment of benefits to persons resident in the territories of Member States.
... Calls on the Member States to undertake the regularisation of immigrant workers who, while not in possession of a residence permit, pay taxes and social security contributions in the host country; ...