O Canada was originally composed in 1880 with French lyrics. Several English versions were written between 1900 and 1920, with (an edited version of) Robert Stanley Weir's lyrics finally winning out.
By the time the Canadian government got around to making it the official anthem the music and French lyrics were in the public domain, but the government had to buy the rights to the English lyrics.
The copyright to Weir's text had passed to Leo Feist Ltd. in 1929 and to Gordon V. Thompson Music in 1932. However, Weir’s heirs did not approve of the change to the lyrics, and though their legal standing was questionable, the government chose to settle the matter amicably. In 1970, both Thompson and Weir's descendants surrendered their rights to the Canadian government for the symbolic sum of one dollar.
— The Canadian Encyclopedia 
The music, English, and French lyrics are all declared to be in the public domain by the National Anthem Act . This seems like it would be a moot point nowadays since their copyrights would all have expired by now, but the law does confirm that the 2018 change of "all our sons" to "all of us" did not change the copyright status.
“O Canada”. The Canadian Encyclopedia. Helmut Kallmann and Gilles Potvin (2012). ↩︎
National Anthem Act. RSC 1985, c N-2. Canada (1980). ↩︎