Legislation passed by French MPs to ban under-15s from accessing social media infringes upon freedom of expression, the country's top court says.