https://gcc.gnu.org/g:a321508c1b91bc9ef5f6029379e579fcdc10cb70
commit r16-7076-ga321508c1b91bc9ef5f6029379e579fcdc10cb70 Author: Iain Buclaw <[email protected]> Date: Tue Jan 27 14:10:52 2026 +0100 d: Fix root modules have no file location set [PR122817] PR d/122817 gcc/d/ChangeLog: * d-lang.cc (d_parse_file): Set module filename location after creation. gcc/testsuite/ChangeLog: * gdc.dg/pr122817.d: New test. Diff: --- gcc/d/d-lang.cc | 2 ++ gcc/testsuite/gdc.dg/pr122817.d | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 7a016050667f..4dc8eede74ad 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -1128,6 +1128,7 @@ d_parse_file (void) Identifier::idPool ("__stdin"), global.params.ddoc.doOutput, global.params.dihdr.doOutput); + m->loc = Loc::singleFilename (in_fnames[i]); modules.push (m); /* Zero the padding past the end of the buffer so the D lexer has a @@ -1148,6 +1149,7 @@ d_parse_file (void) Module *m = Module::create (in_fnames[i], Identifier::idPool (name), global.params.ddoc.doOutput, global.params.dihdr.doOutput); + m->loc = Loc::singleFilename (in_fnames[i]); modules.push (m); FileName::free (name); } diff --git a/gcc/testsuite/gdc.dg/pr122817.d b/gcc/testsuite/gdc.dg/pr122817.d new file mode 100644 index 000000000000..a06a011f5ad3 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr122817.d @@ -0,0 +1,4 @@ +// { dg-do compile } +module pr122817; + +struct object {} // { dg-error "conflicts with import 'pr122817.object' at .*pr122817.d" }
