From patchwork Tue Sep 1 13:01:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 1354986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=martin.st Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=martin-st.20150623.gappssmtp.com header.i=@martin-st.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=rWa83fNu; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BgnJs597qz9sTN for ; Tue, 1 Sep 2020 23:01:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 711033951C06; Tue, 1 Sep 2020 13:01:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by sourceware.org (Postfix) with ESMTPS id 2C912384241D for ; Tue, 1 Sep 2020 13:01:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2C912384241D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=martin.st Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=martin@martin.st Received: by mail-lj1-x241.google.com with SMTP id a15so1416818ljk.2 for ; Tue, 01 Sep 2020 06:01:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=FW7001Xv3/e/8D67ubTPPni0y4HQ4b7JZ/pVS3WJTzw=; b=rWa83fNuonbQgd0r/LM55EA2I42iiSkDVKAxEZ7YPZ5Anmk/YhQUfGGAKvLTgYDAHr ycogy5mVRXuCjTLHs1BNIEVSyhkYnY3bGAAF5QLu4rWOgGuRH9jRuBw/CMq/dEY4zuRY j5CwG58rkLTurzTJiT+GJGMiPHVrz4WXcaX4fj9xNgzYlBwdNOLeBrZ5DZZE8R1URVur EGBWw6LD2QCsnTJTEdlS/z1ruW5tArHQiB2fK3MhZqxUWQ1W6Efw9oAGgICCgWVEWrjC AEBq40hTXkG09PKOyS7slIvX7Dg95fjCnxGpy6YeCV8oNC82NZ5qX+i/Wd6gfErQlAi9 HfBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=FW7001Xv3/e/8D67ubTPPni0y4HQ4b7JZ/pVS3WJTzw=; b=XMr3QrumZobQSCxOqMo8MmEaBv6xcdMZcxUMN/J697P3673x8R1dSwORu4YdwIFNAl tJFkjIPvkvNhFvO0SCRyvj2C2GdY0R9q4qaFhe7EE0nNZrxIFRMlQlTD/BWgT3ulpWPN CMwocgK0SHwltaV7btYx3e8UxYEvwQHHEJelgd7gzt+WIyGKIoiAqqrffCG10EB+c861 QpoCObrEyxH3MxY2hFk3iXWaYmUQvpgFgB8c0xs1RXhH0sbryzNPdx2/454gsOrJgukY HqrlZqBGRulhY7613ncKr37R5wOG53xwRXkv9RA45BlSFU71XqJYUhc/QWYrsBBjuHfl LCdg== X-Gm-Message-State: AOAM530SHj99GHBQItd40igjjBwwwuiBPti6X+9VOwILc5yFAorPFFhu hYX/RaP6lj1Z8mfdf8Jqmh8vn8qwFNBErSre X-Google-Smtp-Source: ABdhPJw+BkXIPyFJux79arV1AF93Pgo80lwNcwckmB4zDwYytDw8qQg0MxtnMaikMpL7WBBuKCIzrA== X-Received: by 2002:a2e:9988:: with SMTP id w8mr587153lji.286.1598965303494; Tue, 01 Sep 2020 06:01:43 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id t12sm269862lfe.43.2020.09.01.06.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 06:01:43 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: gcc-patches@gcc.gnu.org Subject: [PATCH] gcc: Make strchr return value pointers const Date: Tue, 1 Sep 2020 16:01:42 +0300 Message-Id: <20200901130142.6366-1-martin@martin.st> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This fixes compilation of codepaths for dos-like filesystems with Clang. When built with clang, it treats C input files as C++ when the compiler driver is invoked in C++ mode, triggering errors when the return value of strchr() on a pointer to const is assigned to a pointer to non-const variable. This matches similar variables outside of the ifdefs for dos-like path handling. 2020-09-01 Martin Storsjö gcc/Changelog: * dwarf2out.c (file_name_acquire): Make a strchr return value pointer to const. libcpp/Changelog: * files.c (remap_filename): Make a strchr return value pointer to const. --- gcc/dwarf2out.c | 2 +- libcpp/files.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index b6ab49bb548..4096c0c0d69 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -12118,7 +12118,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad) f = strrchr (f, DIR_SEPARATOR); #if defined (DIR_SEPARATOR_2) { - char *g = strrchr (fi->path, DIR_SEPARATOR_2); + const char *g = strrchr (fi->path, DIR_SEPARATOR_2); if (g != NULL) { diff --git a/libcpp/files.c b/libcpp/files.c index 3d48c38fc0a..b890b8ebf1e 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -1693,7 +1693,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file) p = strchr (fname, '/'); #ifdef HAVE_DOS_BASED_FILE_SYSTEM { - char *p2 = strchr (fname, '\\'); + const char *p2 = strchr (fname, '\\'); if (!p || (p > p2)) p = p2; }