EU leaders agreed a referendum on reuniting Ireland would allow Northern Ireland to rejoin the bloc automatically