https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118589
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Gaius Mulley <ga...@gcc.gnu.org>: https://gcc.gnu.org/g:7be54613e8a1b1080f0480cf061baa73317a26d3 commit r15-7200-g7be54613e8a1b1080f0480cf061baa73317a26d3 Author: Gaius Mulley <gaiusm...@gmail.com> Date: Sat Jan 25 00:05:48 2025 +0000 PR modula2/118589 Opaque type fields are visible outside implementation module This patch fixes a bug shown when a variable declared as an opaque type is dereferenced outside the declaration module. The fix also improves error recovery. In the error cases it ensures that an error symbol is created and the appropriate virtual token is assigned. Finally there is a new testsuite directory gm2.dg which contains tests to check against expected error messages. gcc/m2/ChangeLog: PR modula2/118589 * gm2-compiler/M2MetaError.mod (symDesc): Add opaque type description. * gm2-compiler/M2Quads.mod (BuildDesignatorPointerError): New procedure. (BuildDesignatorPointer): Reimplement. * gm2-compiler/P3Build.bnf (SubDesignator): Tidy up error message. Use MetaErrorT2 rather than WriteForma1 and use the token pos from the quad stack. gcc/testsuite/ChangeLog: PR modula2/118589 * lib/gm2-dg.exp (gm2.exp): load_lib. * gm2.dg/pim/fail/badopaque.mod: New test. * gm2.dg/pim/fail/badopaque2.mod: New test. * gm2.dg/pim/fail/dg-pim-fail.exp: New test. * gm2.dg/pim/fail/opaquedefs.def: New test. * gm2.dg/pim/fail/opaquedefs.mod: New test. Signed-off-by: Gaius Mulley <gaiusm...@gmail.com>