From patchwork Fri Oct 28 09:15:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Torbjorn SVENSSON X-Patchwork-Id: 12169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp715394wru; Fri, 28 Oct 2022 02:17:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZaF/1Zir7rnoObvvhD67QW8+HCz1CdqxKHpzZS4MaG3n5eASIWrQgc0yrP0Xe4VvwwLLa X-Received: by 2002:a05:6402:27c6:b0:461:e426:dc8b with SMTP id c6-20020a05640227c600b00461e426dc8bmr21092888ede.403.1666948675601; Fri, 28 Oct 2022 02:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666948675; cv=none; d=google.com; s=arc-20160816; b=JRVvyc6f7soKdp8pk8ZkWpZZeu8Q2Gy0oWjvQlwOqks9ksIVFFqkHYd7M1o86ChDLe hV7uOUdXaR8RAB8JVuZL0saQMWHx5G64s0Zjdqf72ScgKDi7XcQzC9tDi5u7Xcwo66w9 egle2/pq5NxBnoi5D8bb4LdXR50on7Hbx29qKD1EktbJWY+qObZsv5WPx+7OTQB+JImj 6bs8LQ3ZycB7vPStORFSQiLRcznYPqLJAVvJODDAcqYg9c3IVo4rkwV0dOd+F9m2XuWP 619yELXIMjHaqPG0/e7xUbWCA57XRVGsKI0PLk8Oh/qrYY7Hpjmxk4724vXyPsPUNFAL bKBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=/ID5mXjMtnSmnWqMuGhSxdvHKFolnkax3ODVl+GB1gI=; b=BwjkjHUvSITl+M7V79KX8FM43QzXWBqwI+uAwpFyxNLyofCiDCNg8s5Tdor4ony7oV /Y132pl7nuvNLTKVYnMa53ZfoIvziFyM4GOkv4V1KzVUs71+YB1ja/C5xvcFl9P5oTvI Vc6C0MwDLE7InNso6h7VZXSeE+cIS3kgSSAIjjPnadn1zbuU/Joq3HlRLyuX+gFGoVGs wL+s75f4XuHo+K4rib6D30QGg4t8XxZJQSGzJOSo4nmljMkvr+8OJBQuRE/ckYO38Adm SL9oFFpocyCdMB7dEUMj73DyZ30ObX5b5pBoi3enLpKobwDhcSXD1xjOnG5ueLyY0k3C B0zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hDHvlj5V; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q7-20020a50cc87000000b00461540620f1si3577248edi.169.2022.10.28.02.17.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 02:17:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hDHvlj5V; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 668723858C50 for ; Fri, 28 Oct 2022 09:17:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 668723858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666948674; bh=/ID5mXjMtnSmnWqMuGhSxdvHKFolnkax3ODVl+GB1gI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=hDHvlj5VzVlZ6KmZjrxmoP7ROipJZ4ODH9OUIdZezKqd49uc5lSBMtSCyw0B1XtMx yNsoaai6NCpBlSCFNeZO/wkpJKMg0k/B5WJ1ootLnTa+ygiyaMVkqTVfgD3ADYMCCf o0s2f15J5HbsnCoIBFDjs/RE0evOBcDcnZKlO4Tc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by sourceware.org (Postfix) with ESMTPS id 674AB3858C2D for ; Fri, 28 Oct 2022 09:17:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 674AB3858C2D Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29S8CYSH006733; Fri, 28 Oct 2022 11:16:51 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3kfajfbhnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 11:16:51 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 29E8110002A; Fri, 28 Oct 2022 11:16:45 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B9C95216832; Fri, 28 Oct 2022 11:16:45 +0200 (CEST) Received: from jkgcxl0002.jkg.st.com (10.210.54.218) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 28 Oct 2022 11:16:45 +0200 To: Subject: [PATCH] c++: Allow module name to be a single letter on Windows Date: Fri, 28 Oct 2022 11:15:01 +0200 Message-ID: <20221028091500.2748920-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.210.54.218] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-28_04,2022-10-27_01,2022-06-22_01 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Torbj=C3=B6rn_SVENSSON_via_Gcc-patches?= From: Torbjorn SVENSSON Reply-To: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= Cc: nathan@acm.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747922374549058886?= X-GMAIL-MSGID: =?utf-8?q?1747922374549058886?= 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. include/ChangeLog: * filenames.h: Added IS_REAL_ABSOLUTE_PATH macro to check if path is absolute and not semi-absolute on Windows. gcc/cp/ChangeLog: * module.cc: Use IS_REAL_ABSOLUTE_PATH macro. Co-Authored-By: Yvan ROUX Signed-off-by: Torbjörn SVENSSON --- gcc/cp/module.cc | 2 +- include/filenames.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 9957df510e6..84680e183b7 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13958,7 +13958,7 @@ 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)) + if (ptr[0] == '.' ? IS_DIR_SEPARATOR (ptr[1]) : IS_REAL_ABSOLUTE_PATH (ptr)) /* A header name. */ return get_module (build_string (strlen (ptr), ptr)); diff --git a/include/filenames.h b/include/filenames.h index 6c72c422edd..d04fccfed64 100644 --- a/include/filenames.h +++ b/include/filenames.h @@ -43,6 +43,7 @@ extern "C" { # define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f) # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c) # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f) +# define IS_REAL_ABSOLUTE_PATH(f) IS_DOS_REAL_ABSOLUTE_PATH (f) #else /* not DOSish */ # if defined(__APPLE__) # ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM @@ -52,6 +53,7 @@ extern "C" { # define HAS_DRIVE_SPEC(f) (0) # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c) # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f) +# define IS_REAL_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH (f) #endif #define IS_DIR_SEPARATOR_1(dos_based, c) \ @@ -67,6 +69,8 @@ extern "C" { #define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c) #define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f) +#define IS_DOS_REAL_ABSOLUTE_PATH(f) \ + ((f)[0] && (f)[1] == ':' && ((f)[2] == '/' || (f)[2] == '\\')) #define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f) #define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c)