The parent of a child who has attained the age of majority and who has obtained access to education on the basis of Article 12 of Regulation No 1612/68 on freedom of movement for workers within the Community as amended by Directive 2004/38, may continue to have a derived right of residence under that article if that child remains in need of the presence and care of that parent in order to be able to continue and to complete his or her education, which it is for the referring court to assess, taking into account all the circumstances of the case before it.

Periods of residence in a host Member State which are completed by family members of a Union citizen who are not nationals of a Member State solely on the basis of Article 12 of Regulation No 1612/68 on freedom of movement for workers within the Community, as amended by Directive 2004/38, where the conditions laid down for entitlement to a right of residence under Directive 2004/38 are not satisfied, may not be taken into consideration for the purposes of acquisition by those family members of a right of permanent residence under that directive.

The acquisition of a right of permanent residence by family members of a Union citizen who are not nationals of a Member State is dependent, in any event, on the fact that, first, the Union citizen himself satisfies the conditions laid down in Article 16(1) of that directive, namely that he has resided legally for a continuous period of five years in the host Member State and, secondly, those family members have resided with him for the period in question.

As regards, first, the conditions which must be satisfied by the Union citizen, the concept of legal residence should be construed as meaning a period of residence which complies with the conditions laid down in that directive, in particular those set out in Article 7(1) thereof. Consequently, a period of residence which complies with the law of a Member State but does not satisfy the conditions laid down in Article 7(1) cannot be regarded as legal residence within the meaning of Article 16(1) of Directive 2004/38.

As regards, secondly, the acquisition of a right of permanent residence by the family members of a Union citizen who are not nationals of a Member State, the requirement of residence with that citizen in the host Member State for the period concerned implies that those family members necessarily and concurrently have a right of residence under Article 7(2) of Directive 2004/38, as family members accompanying or joining that citizen. It follows that, for the purposes of that acquisition, only the periods of residence of those family members which satisfy the condition of accompanying or joining in the host Member State a Union citizen who himself satisfies the conditions laid down in Article 7(1)(a), (b) or (c) of Directive 2004/38 may be taken into consideration.

Consequently, the fact that the family member of a Union citizen who is not a national of a Member State has resided in a Member State solely on the basis of Article 12 of Regulation No 1612/68 cannot have any effect on the acquisition of a right of permanent residence under Directive 2004/38.

(see paras 34-37, 39, 40, 48, operative part 2)