From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7897) id 62860385B19A; Mon, 28 Nov 2022 15:50:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62860385B19A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669650618; bh=ibTv62iEF+jjlYap6q/6yqaSM36wskqbE3UrPL/t/Vg=; h=From:To:Subject:Date:From; b=nMTsjLpZj7VGA+X1JTz1fdfIShPWXet7REUlNUWNhz2RpYFj7pNGV0aPuPgVfmyIF tuzZ6t11iimlyi+HHf9sKWMJAB2A1uUXcngWfgkKkxUQ6WMwd9LqdJf1CKbQarqJIJ ZvJN+1ZeziqRtfc5rx3gsvGdWa0q3+hHUBL2QkY8= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Torbjorn Svensson To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4367] c++: Allow module name to be a single letter on Windows X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= X-Git-Refname: refs/heads/master X-Git-Oldrev: c775e2b81fca39f366040d423e3e44f4abecf753 X-Git-Newrev: d30e98b54d6a5124bb48b10b593e264f048d38aa Message-Id: <20221128155018.62860385B19A@sourceware.org> Date: Mon, 28 Nov 2022 15:50:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d30e98b54d6a5124bb48b10b593e264f048d38aa commit r13-4367-gd30e98b54d6a5124bb48b10b593e264f048d38aa Author: Torbjörn SVENSSON Date: Thu Oct 27 18:03:15 2022 +0200 c++: Allow module name to be a single letter on Windows On Windows, the ':' character is special and when the module name is a single character, like 'A', then the flatname would be (for example) 'A:Foo'. On Windows, 'A:Foo' is treated as an absolute path by the module loader and is likely not found. Without this patch, the test case pr98944_c.C fails with: In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_b.C:7:1, of module A:Foo, imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7: A:Internals: error: header module expected, module 'A:Internals' found A:Internals: error: failed to read compiled module: Bad file data A:Internals: note: compiled module file is 'gcm.cache/A-Internals.gcm' In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7:8: A:Foo: error: failed to read compiled module: Bad import dependency A:Foo: note: compiled module file is 'gcm.cache/A-Foo.gcm' A:Foo: fatal error: returning to the gate for a mechanical issue compilation terminated. gcc/cp/ChangeLog: * module.cc: On Windows, 'A:Foo' is supposed to be a module and not a path. Co-Authored-By: Yvan ROUX Signed-off-by: Torbjörn SVENSSON Diff: --- gcc/cp/module.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index a1764354ba5..7133009dba5 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13987,7 +13987,15 @@ get_module (tree name, module_state *parent, bool partition) static module_state * get_module (const char *ptr) { - if (ptr[0] == '.' ? IS_DIR_SEPARATOR (ptr[1]) : IS_ABSOLUTE_PATH (ptr)) + /* On DOS based file systems, there is an ambiguity with A:B which can be + interpreted as a module Module:Partition or Drive:PATH. Interpret strings + which clearly starts as pathnames as header-names and everything else is + treated as a (possibly malformed) named moduled. */ + if (IS_DIR_SEPARATOR (ptr[ptr[0] == '.']) // ./FOO or /FOO +#if HAVE_DOS_BASED_FILE_SYSTEM + || (HAS_DRIVE_SPEC (ptr) && IS_DIR_SEPARATOR (ptr[2])) // A:/FOO +#endif + || false) /* A header name. */ return get_module (build_string (strlen (ptr), ptr));