From patchwork Tue May 17 08:27:37 2022 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: 54072 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC4FE3857402 for ; Tue, 17 May 2022 08:38:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC4FE3857402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652776711; bh=vMOO2ZQ7oIuDomN+X/1CkzrvwKYEyc3Ezo4fPiL70II=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=xLcJpzyFX96B5VTB3Y1bobxI4IyUxWs1GphJbE5qr9E06EzUcW1El9/e+i80xAvbq x/Bivmdl+ZkBlR8WD8MV9lyc8iR7/H2Map6yVw4DrTA6l+fwDU5J9z9Whf2popN+Ug Jy0u0HaQGBk7dYFkAvFouRWMm9EG5oXbAZwZg8tw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 1389A3858C56 for ; Tue, 17 May 2022 08:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1389A3858C56 Received: by mail-wm1-x336.google.com with SMTP id a14-20020a7bc1ce000000b00393fb52a386so929182wmj.1 for ; Tue, 17 May 2022 01:27:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=vMOO2ZQ7oIuDomN+X/1CkzrvwKYEyc3Ezo4fPiL70II=; b=fTxLiL+0oCBAAg+g7Zgemlio4YH8GEm0DUptei8b36m889A0XPULCVRuySJNEneOLX B7EWrGm1ydlPshzVQ4Kone0eC9nrplB9jUoISBeaUZBPtDlple5J2CZSiyGXYWJsDB3K 9o4WWoV+sJiwJfrKN0ANdBeTlv08c/gOSJ0Icoxy2EGUeGNLcQWlfvxAEVO1Jxc8SVV7 CK6xjkn/2CMN57QQIXZAvnCzFG7F7fa3UH7SwHpDc9yRnfSt+GGvkWsWoF0YgHekBW0F pMwSGY+m6w6Zg9GP3nKvT/BYPU/tlaJL0U3Se/ZdYZZBI76tofQNyBgfPb7Es8nsLyQW uoDA== X-Gm-Message-State: AOAM531+HPrxhdAQuOlaArwO7M9trmpKAdgKD0kAmv33gkWAJNvJKujX LM0wg477cIaBbORy7N9auOZ93F+m4q8jUuRA X-Google-Smtp-Source: ABdhPJwyenUhMM2igRSrhM6yifyDcEKjL4DvNsYXuvt8oyjUbFVmP61+JrIFevMlCdM9if1omEoPYg== X-Received: by 2002:a05:600c:350e:b0:394:9204:6fc8 with SMTP id h14-20020a05600c350e00b0039492046fc8mr20415361wmq.74.1652776057865; Tue, 17 May 2022 01:27:37 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id ay12-20020a05600c1e0c00b003942a244edbsm1497814wmb.32.2022.05.17.01.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 01:27:37 -0700 (PDT) Date: Tue, 17 May 2022 08:27:37 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Initialize Compiler_State to avoid Constraint_Error Message-ID: <20220517082737.GA1088903@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Etienne Servais Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" When building gnat1 with `-gnatVa` as we do locally, rules like: `gcc -c -gnatyM79 ` will throw a constraint error as `lib.compiler_state` is initialized by par.adb, ie after scanning. Therefore any error_msg thrown during scanning will perform this uninitialized read (which raises a Constraint_Error when the compiler was compiled with `-gnatVa`). Initialize this flag to `Parsing`. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib.ads: initialize `Compiler_State` to `Parsing`. diff --git a/gcc/ada/lib.ads b/gcc/ada/lib.ads --- a/gcc/ada/lib.ads +++ b/gcc/ada/lib.ads @@ -39,7 +39,7 @@ package Lib is -- Type to hold list of indirect references to unit number table type Compiler_State_Type is (Parsing, Analyzing); - Compiler_State : Compiler_State_Type; + Compiler_State : Compiler_State_Type := Parsing; -- Indicates current state of compilation. This is used to implement the -- function In_Extended_Main_Source_Unit.