From patchwork Sat Jan 27 20:51:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1891816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=eNq6F3jq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMmvS5zsJz23fN for ; Sun, 28 Jan 2024 07:51:48 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A31AF3858404 for ; Sat, 27 Jan 2024 20:51:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id E88163858C60 for ; Sat, 27 Jan 2024 20:51:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E88163858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E88163858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706388689; cv=none; b=IdyPkrAJMMnBS2Uf5iu0vfDhUxiNzXB7Cz93aYypGTFN/DnZdTNYGZpJ6gjrMLXv+RUJWN04eChBFCqIZiB8KGkPDpotRk8/jyX0V9LL7KIcj08LJA+Xxtj2rN7f+psUzC1TYGepDDTDoqIyR79U3VSj/wLXX64cKK9N8IZ85jE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706388689; c=relaxed/simple; bh=R4hSSR2qRsF3st1LgRaCGL9zIeCzG6YjDjNcs4+raxo=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=BuXJ95xVNmn2hMCggBaSv1rtcPdTQftU/5ijglZgiaPOdn1aygPbRy94hSCgh12M4WAxOXTFMOssbeHoXSn6A5b3mTndbeHlyp5cIwywk4InOATfGV2IQe3ZysMPOYAPZofQPA0uxGW030KHxFYC0sIqiCnF2nf9OBOK3pYF1Vk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-290b37bb7deso1469452a91.0 for ; Sat, 27 Jan 2024 12:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706388687; x=1706993487; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=iSBwUi5PzeMWsVCKTstlwQAgues176c79osCcJo8VKE=; b=eNq6F3jqB4hJhGSkwBCPR+78U7yBHy12l/DO7yAda7Vztc8QCdDdb3jozFugcnBb5Q gFowRopfukHSanIS9XCV+w9tckihex1uJ7xkn0UNFTy2KvXFmZ7rj/4RIOdlABgLQyST rBjGt4T+8M5KE2ybNL7WxFBg2HzohczzRWDfgt2X9UURTaLo/AJi7y48I7KYh5RSr4Rm 9Y2yYv/3DMBZfQmgQwl8DPtmFfxJOVtbNFYv1awkdC8AJl2V4e8LsTNcRc73FxdF6Roj NwVk9YjjPrQlo+4rc4afVrDd+1AQZjDJ3fRehbPXwzqrIfDvmoYYaCsv8yTS6ABIM6xF sNLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706388687; x=1706993487; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iSBwUi5PzeMWsVCKTstlwQAgues176c79osCcJo8VKE=; b=SCV6HBpoZvfMKRsBCBNPzLqPtub9uPpiHVTWZj5/Mefv8NV/NcNtF8AQqg97GuXR0V WBcZgqZz4wwd3ZCiHJt+4yOlBqsAaBf9ILum8ACoAyIBNFUSvT5D1cpRAryP6EqVtsoK Xf0uZOqgdtv1XqdibuzNmsje7jfT35p67MTc7rCsh+aWYQOrCJyHc8HDG8tq1PZ83ggN VAzvX/HC4XRokrDi+eH/k5ylOWy9RHKZXrdcfuL2RagIR7kBKJzYmLyNoQGeqPLY3IHA sHtAC9o1Ax08aG2nsjqoMFwBVSk0JDXJUxrhjDFdWnHHIm3SoK+M9k4QJmVoNehqgTOp Wr5w== X-Gm-Message-State: AOJu0YxoGc00QIOLzdEzxg5VdhS3O+BM6zZi9ytLh2sEDdY0PeOp/Ben AsGHuwedtCtbTm7WwPprOHNaPCPoYk5Hk/HdYbIbyVqkpC1DN1Cd2AkZ+IXU X-Google-Smtp-Source: AGHT+IFXv0upVeYmq3hnCeCqeDVo6Xh5Gab/vBnBZCwhxcduBwLUa+84w4+XXZX2cbjHcHavuIYw1w== X-Received: by 2002:a17:902:e548:b0:1d7:215a:8065 with SMTP id n8-20020a170902e54800b001d7215a8065mr2410242plf.34.1706388686776; Sat, 27 Jan 2024 12:51:26 -0800 (PST) Received: from Thaum. (123-243-206-49.tpgi.com.au. [123.243.206.49]) by smtp.gmail.com with ESMTPSA id g13-20020a170902c38d00b001d8a920387csm2108433plg.148.2024.01.27.12.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 12:51:26 -0800 (PST) Message-ID: <65b56cce.170a0220.25f58.78f9@mx.google.com> X-Google-Original-Message-ID: Date: Sun, 28 Jan 2024 07:51:20 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Nathan Sidwell , Jason Merrill Subject: [PATCH] c++/modules: Handle error header names in modules [PR107594] MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org I don't provide a new test because this error only happens when there are no include paths at all, and I haven't worked out a way to get this to happen within DejaGNU (as it adds a number of `-B` and `-I` flags). Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- When there are no include paths while preprocessing a header-name token, an empty STRING_CST is returned. This patch ensures this is handled when attempting to create a module for this name. PR c++/107594 gcc/cp/ChangeLog: * module.cc (get_module): Bail on empty name. Signed-off-by: Nathaniel Shead --- gcc/cp/module.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 840c7ef6dab..3c2fef0e3f4 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -14050,6 +14050,12 @@ get_primary (module_state *parent) module_state * get_module (tree name, module_state *parent, bool partition) { + /* We might be given an empty NAME if preprocessing fails to handle + a header-name token. */ + if (name && TREE_CODE (name) == STRING_CST + && TREE_STRING_LENGTH (name) == 0) + return nullptr; + if (partition) { if (!parent)