From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 3668D3850853 for ; Wed, 13 Jul 2022 10:03:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3668D3850853 Received: by mail-ed1-x531.google.com with SMTP id x91so13434461ede.1 for ; Wed, 13 Jul 2022 03:03:03 -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=CDmz/BuvYYvOtTfw6q23Ike19X67BmlbgbDrdM3RXy0=; b=3ySyoJ4ixIXeIKSymYbxs22iaw2N+pRzaAez3NDcMYxkweLd4+/ZSc1Sb3HHjN9AEA 8qHyWcL0DpZTnVAyvp0i6nJKnDU1u7lbBm8pQupz/LE5NmTMASR5855glGlLwBGiaxQJ 3nAhNigCnW07JVZ6UUqm80AAlyUkH3LGAArWJhDl8/RBpPgvXQdJ64ohaL1staUhJIEu xaGnrF46ulHNFQi4OtC3m1BiXgHymhEKg17Wob+laDaWWEwfJ/ursV0apj0mefhXlF2y EvrGoYayYZ3YxeSt9rx/F7FywpMGjSUD6Hbk1IWAVRmdSOd5hIgfJCbmZV74/t5LKDRA b/Ew== X-Gm-Message-State: AJIora9scr9b2BAwxHg1xlUj5aFvTngNQs/0hNqESH+J04NIJlwECcai ujrEssml+fssUheFki1TN819HjpZVCMqug== X-Google-Smtp-Source: AGRyM1tj/WFBbGaEbB1USK+HVltuBBuWpKExmoNGhNWDhxqd3+hEnuKYTqP/39Z9hWuKGKst+xbAyw== X-Received: by 2002:a05:6402:2812:b0:43a:9041:d5db with SMTP id h18-20020a056402281200b0043a9041d5dbmr3601647ede.208.1657706581942; Wed, 13 Jul 2022 03:03:01 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id h8-20020aa7cdc8000000b004355998ec1asm7575395edw.14.2022.07.13.03.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 03:03:01 -0700 (PDT) Date: Wed, 13 Jul 2022 10:03:00 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix internal error on instance of Ada.Task_Attributes at -O Message-ID: <20220713100300.GA994742@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" 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-List-Received-Date: Wed, 13 Jul 2022 10:03:08 -0000 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This happens when there is a size mismatch, but this must be accepted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.cc (unchecked_convert): Also pad in most cases if the source is not a scalar type but the destination is. --Q68bSM7Ycu6FN28Q Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -5503,8 +5503,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) expr = unchecked_convert (type, expr, notrunc_p); } - /* If we are converting from a scalar type to a type with a different size, - we need to pad to have the same size on both sides. + /* If we are converting between fixed-size types with different sizes, we + need to pad to have the same size on both sides. ??? We cannot do it unconditionally because unchecked conversions are used liberally by the front-end to implement interface thunks: @@ -5515,8 +5515,10 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) so we need to skip dereferences. */ else if (!INDIRECT_REF_P (expr) - && !AGGREGATE_TYPE_P (etype) + && TREE_CODE (expr) != STRING_CST + && !(AGGREGATE_TYPE_P (etype) && AGGREGATE_TYPE_P (type)) && ecode != UNCONSTRAINED_ARRAY_TYPE + && TREE_CONSTANT (TYPE_SIZE (etype)) && TREE_CONSTANT (TYPE_SIZE (type)) && (c = tree_int_cst_compare (TYPE_SIZE (etype), TYPE_SIZE (type)))) { @@ -5532,15 +5534,18 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) tree rec_type = maybe_pad_type (type, TYPE_SIZE (etype), 0, Empty, false, false, true); expr = unchecked_convert (rec_type, expr, notrunc_p); - expr = build_component_ref (expr, TYPE_FIELDS (rec_type), false); + expr = build3 (COMPONENT_REF, type, expr, TYPE_FIELDS (rec_type), + NULL_TREE); } } - /* Likewise if we are converting from a scalar type to a type with self- + /* Likewise if we are converting from a fixed-szie type to a type with self- referential size. We use the max size to do the padding in this case. */ else if (!INDIRECT_REF_P (expr) - && !AGGREGATE_TYPE_P (etype) + && TREE_CODE (expr) != STRING_CST + && !(AGGREGATE_TYPE_P (etype) && AGGREGATE_TYPE_P (type)) && ecode != UNCONSTRAINED_ARRAY_TYPE + && TREE_CONSTANT (TYPE_SIZE (etype)) && CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type))) { tree new_size = max_size (TYPE_SIZE (type), true); @@ -5557,7 +5562,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) tree rec_type = maybe_pad_type (type, TYPE_SIZE (etype), 0, Empty, false, false, true); expr = unchecked_convert (rec_type, expr, notrunc_p); - expr = build_component_ref (expr, TYPE_FIELDS (rec_type), false); + expr = build3 (COMPONENT_REF, type, expr, TYPE_FIELDS (rec_type), + NULL_TREE); } } --Q68bSM7Ycu6FN28Q--