Article 218(11) TFEU: A Member State, the European Parliament, the Council or the Commission may obtain the opinion of the Court of Justice as to whether an agreement envisaged is compatible with the Treaties. Where the opinion of the Court is adverse, the agreement envisaged may not enter into force unless it is amended or the Treaties are revised.
Article 263 TFEU: The Court of Justice of the European Union shall review the legality of legislative acts, of acts of the Council, of the Commission and of the European Central Bank, other than recommendations and opinions, and of acts of the European Parliament and of the European Council intended to produce legal effects vis-à-vis third parties. It shall also review the legality of acts of bodies, offices or agencies of the Union intended to produce legal effects vis-à-vis third parties.
It shall for this purpose have jurisdiction in actions brought by a Member State, the European Parliament, the Council or the Commission on grounds of lack of competence, infringement of an essential procedural requirement, infringement of the Treaties or of any rule of law relating to their application, or misuse of powers.
As you can see a Member State, the European Parliament, the Council and the Commission have the possibility to contest the legality of an international agreement ex-ante based on 218 TFEU or to challenge it ex-post based in 263 TFEU. What is the consequence of not asking an opinion under 218 TFEU in a case of challenging the legality of an international agreement ex-post?
http://www.oup.com/uk/orc/bin/9780199587735/resources/overviews/hargreaves2e_p63.pdf