From patchwork Tue Jun 15 10:20:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1492103 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 4G44Gb0d9jz9sW8 for ; Tue, 15 Jun 2021 20:25:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0BBBC398EC23 for ; Tue, 15 Jun 2021 10:25:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id AE677398B17B for ; Tue, 15 Jun 2021 10:20:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE677398B17B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 65A94117B4B; Tue, 15 Jun 2021 06:20:52 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id drBVqU8OnCMX; Tue, 15 Jun 2021 06:20:52 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 32EAD117B14; Tue, 15 Jun 2021 06:20:52 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 31C751CA; Tue, 15 Jun 2021 06:20:52 -0400 (EDT) Date: Tue, 15 Jun 2021 06:20:52 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Remove const qualifier on a couple of pointed-to types Message-ID: <20210615102052.GA3199@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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: , Cc: Eric Botcazou Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" gnat_argv is defined as pointer to const memory in argv.c but declared and accessed as pointer to mutable memory in rtinit.c, which breaks the One Definition Rule in C++. Its initialization is also non-standard. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * argv.c: Add include of for the runtime. (gnat_argv): Change type to char ** and initialize to NULL. (gnat_envp): Likewise. * argv-lynxos178-raven-cert.c: Add include of . (gnat_argv): Change type to char ** and initialize to NULL. (gnat_envp): Likewise. diff --git a/gcc/ada/argv-lynxos178-raven-cert.c b/gcc/ada/argv-lynxos178-raven-cert.c --- a/gcc/ada/argv-lynxos178-raven-cert.c +++ b/gcc/ada/argv-lynxos178-raven-cert.c @@ -41,6 +41,7 @@ minimal support for Ada.Command_Line.Command_Name */ #include +#include #include #ifdef __cplusplus @@ -53,8 +54,8 @@ extern "C" { the binder-generated file so they need to be defined here */ int gnat_argc = 0; -const char **gnat_argv = (const char **) 0; -const char **gnat_envp = (const char **) 0; +char **gnat_argv = NULL; +char **gnat_envp = NULL; int __gnat_len_arg (int arg_num) diff --git a/gcc/ada/argv.c b/gcc/ada/argv.c --- a/gcc/ada/argv.c +++ b/gcc/ada/argv.c @@ -44,6 +44,7 @@ #ifdef IN_RTS #include "runtime.h" +#include #include #else #include "config.h" @@ -60,14 +61,13 @@ extern "C" { envp of the main program is saved under gnat_envp. */ int gnat_argc = 0; -const char **gnat_argv = (const char **) 0; -const char **gnat_envp = (const char **) 0; +char **gnat_argv = NULL; +char **gnat_envp = NULL; #if defined (_WIN32) && !defined (RTX) /* Note that on Windows environment the environ point to a buffer that could be reallocated if needed. It means that gnat_envp needs to be updated before using gnat_envp to point to the right environment space */ -#include /* for the environ variable definition */ #define gnat_envp (environ) #endif