]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix root modules have no file location set [PR122817]
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 27 Jan 2026 13:10:52 +0000 (14:10 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 27 Jan 2026 20:35:25 +0000 (21:35 +0100)
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.

gcc/d/d-lang.cc
gcc/testsuite/gdc.dg/pr122817.d [new file with mode: 0644]

index 7a016050667f57d1b9dce982fd7eb8ed2a3d0bb7..4dc8eede74ad0ba2e52704df692613c8a6cd54ea 100644 (file)
@@ -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 (file)
index 0000000..a06a011
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do compile }
+module pr122817;
+
+struct object {} // { dg-error "conflicts with import 'pr122817.object' at .*pr122817.d" }