From patchwork Tue Jan 9 09:50:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1884353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=iOY6dklu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T8R5L4TNDz1yP7 for ; Tue, 9 Jan 2024 20:51:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E493385829B for ; Tue, 9 Jan 2024 09:51:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id DE8703858C2F for ; Tue, 9 Jan 2024 09:50:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE8703858C2F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DE8703858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704793832; cv=none; b=l6PQuE7Lp9/NuuIfaXhHsrTtLhVtd7tcN6btX40BIf1F2gkhXAN58T4n3p7DESrBzmoZcvSINr7BYm+JKh2A+0r1ofMIwYekaTVXEob06ukFLfReUbCY2/IGapX39yUgTeLAT4B46aKr23eY/XkbPo055wnPdKzkLknsHGMs0z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704793832; c=relaxed/simple; bh=V56COnDxwKFXqxVeBzHvIbtTZ5oc3C9zN4NSHRNkqwU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rDV7HPp3ilvd1Zgqzn5/U6imDU74nZtAHz7ijyCDESuBiNKhRNcj6KkRnbvP6JO3Lb0TVuJX1BjJ7t/meNQgl5JjTZMFWLWCzMY28bFc2KhtNcGcNfkc8n1PQozzmXflYS24xbOR1d+/dOPhr6wA+JsWYdGBuxSw3itvYB9rHrQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33678156e27so2658524f8f.1 for ; Tue, 09 Jan 2024 01:50:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1704793828; x=1705398628; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=bhz5utQZgBsTxN+dXdQw/sbLtQYzn3QpIRe7u0pbDDk=; b=iOY6dkluGV19he7eUJjGbssJRK7xtVomaAlbl0cUoAQ0/10sh+6HIthZNHbgOIwLD+ jOGez5HdB/dddZuYnXLKSHhZwVetNguI+tvcRhUI3Yq4Xt/QcWus0zZtmpMS4niEYFlX RYr7xe6SvQp6hJLnFBmb3kJGJ+1uEig6aHugvIsrPQ4u8n7JoN5JZOkVecWH8xmkKInA Bd2Tx4v/t6OOFJtjxnYL5sTsNai1MXXN19Jp4W0c9fPxgftQYpq+cFpOqVOl8F3g0DjR k7yEBaJuaU5NPZddBtbTbF1T3PoWnj2xea9QPs/GFSgrxSnExCV5hds5QDyxZ34Y81e4 bDHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704793828; x=1705398628; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bhz5utQZgBsTxN+dXdQw/sbLtQYzn3QpIRe7u0pbDDk=; b=tL5F1kbQSI23ho+xCAMeEHQtyavjvTivqNDg1LD5QQOgvKwAEvL05GO1yfaEatkdYz HyywS/5HA9t8RxYiPcI7/23QVaN8ySupm8G+R25MVyKQEzDzUsBiWhI5kuMwMGDdN3fe Y8PrxdgPqFuVfAqrg9b2F4GrCXQb4jE7Q19qcyxzHkOmeu2tC0qxQUTGN9/RLx7Jb05b tuGwjGQaDbmwszus5Y+/bryCN0eoubOXEi4YrWAePvgqUhDwO7gGrdByrObiKpxiNZ2A LleIHknp32psMGmIBh/7dCV5NFl+WC448OZOmA+Zz393cFsIvGY89SF/D2TFFFBCexpE B8Eg== X-Gm-Message-State: AOJu0Yypw/OIDyUAk0k+GEfxBfc/TVHZNXbESbIuE/tOkz9ML5T+Gdsd q0RjTx7wkWT8jX6q/b70yBHkscsqRRIWsGY/wUKw5shiuQ== X-Google-Smtp-Source: AGHT+IGZwrRae8o7YaspIZ8cxUujXlRmgf2DF+LQLED97Cz+sTzQrLi+snrK/bHJlJso/6qM5Sag4w== X-Received: by 2002:adf:fac7:0:b0:337:652d:39d6 with SMTP id a7-20020adffac7000000b00337652d39d6mr377992wrs.55.1704793828633; Tue, 09 Jan 2024 01:50:28 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id h10-20020adff4ca000000b0033668b27f8fsm1955841wrp.4.2024.01.09.01.50.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:50:28 -0800 (PST) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix PR ada/112781 (1/2) Date: Tue, 09 Jan 2024 10:50:27 +0100 Message-ID: <2177833.Mh6RI2rZIc@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This is a regression present on the mainline and 13 branch, in the form of a series of internal errors (3) on a function call returning the extension of a limited interface. This is only a partial fix for the first two assertion failures triggered by this case; the third one is the most problematic and will be dealt with separately. The first issue is in Instantiate_Type, where we use Base_Type in a specific case to compute the ancestor of a derived type, which will later trigger the assertion on line 16960 of sem_ch3.adb since Parent_Base and Generic_Actual are the same node. This is changed to use Etype like in other cases around. The second issue is an unprotected use of Designated_Type on type T in Analyze_Explicit_Dereference, while another use in an equivalent context is guarded by Is_Access_Type a few lines above. Tested on SPARC64/Linux, applied on the mainline and 13 branch. 2024-01-09 Eric Botcazou PR ada/112781 * sem_ch12.adb (Instantiate_Type): Use Etype instead of Base_Type consistently to retrieve the ancestor for a derived type. * sem_ch4.adb (Analyze_Explicit_Dereference): Test Is_Access_Type consistently before accessing Designated_Type. diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index bfb400f5642..d2285082f97 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -13522,8 +13522,7 @@ package body Sem_Ch12 is Ancestor := Get_Instance_Of (Ancestor); else - Ancestor := - Get_Instance_Of (Base_Type (Get_Instance_Of (A_Gen_T))); + Ancestor := Get_Instance_Of (Etype (Get_Instance_Of (A_Gen_T))); end if; -- Check whether parent is a previous formal of the current generic diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 64aa9a84e60..85ae282dc37 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -2304,7 +2304,9 @@ package body Sem_Ch4 is while Present (It.Nam) loop T := It.Typ; - if No (First_Formal (Base_Type (Designated_Type (T)))) then + if Is_Access_Type (T) + and then No (First_Formal (Base_Type (Designated_Type (T)))) + then Set_Etype (P, T); else Remove_Interp (I);