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: Martin Storsjo X-Patchwork-Id: 248862 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4214666ilg; Tue, 1 Sep 2020 06:01:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYacoFkQq6nf4wtrnEBrGbI2gk8MM10d4WFSCpqN4S+jVhivYK6200Xawkxjhhj5Gxpjtd X-Received: by 2002:a17:906:26d9:: with SMTP id u25mr1436935ejc.318.1598965308598; Tue, 01 Sep 2020 06:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598965308; cv=none; d=google.com; s=arc-20160816; b=N15nXgriRNfc2cMOmb+EygxwOhcnD4A957CnTbw3JvcdFZwiPZDk0cNCdjzBD9Ng6p DsCyRw+xt9NTVFX9D5Q892GBs0fxiAC8njFTPvFz+IgwF+l7yCp2DHcnu0dLlnM/61A0 uBZD3SA+GR86q/fo1yvwCGePjvCbAk5PwD8halSAU8BEMuH107+Psr1H4TOcIkMzkdUf qtZ7ReTBMCD1et2F4+YPuB6ufiqZVC+P+qcVHGPF55tPZ1K02p5Cmds/yd7IV6eCUYkU YyQvOjtzbwLEr+f+zzRsw+mdncsZPSCeLD3LVdpiGq2T6s8sMuUgy6afMDfkrQjY1gtI irxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=FW7001Xv3/e/8D67ubTPPni0y4HQ4b7JZ/pVS3WJTzw=; b=XI/u4XxKT1JgP5bGrSfHFcv1t0rj3AdmOCEsROE5+lokYqU29/SdE/Dc13tQstSiAt XQG/bFwwMTevrpTRQ9d9qn7fboN+dnS/C/zAOsYCj9W9uHXCRiXksEzNd6JeIv/J0iDT FFmZStL+1lsT4N9JpNLTF7gqwNtZ927zopcUXd8nZkgbZ3pMIJIzZCBMp7pZwJ6SRmBL eeH0zGwbxaWq09/JIb34V+h7Ax+cdPRB/ZrvuVgQh1aOPgW1MXiUC2QiBbUITf0IaQPg w/DfJlJ1Tl3HLv/qGAs6vgQhgVqwnbQSXoVEeVs6gmHR8BYi35aBoJbm0tKINiFnc8Ew ISnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@martin-st.20150623.gappssmtp.com header.s=20150623 header.b=rWa83fNu; spf=pass (google.com: domain of gcc-patches-bounces@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom=gcc-patches-bounces@gcc.gnu.org Return-Path: Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n26si606380eji.66.2020.09.01.06.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 06:01:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces@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=@martin-st.20150623.gappssmtp.com header.s=20150623 header.b=rWa83fNu; spf=pass (google.com: domain of gcc-patches-bounces@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom=gcc-patches-bounces@gcc.gnu.org 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-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(-) -- 2.17.1 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; }