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: 186302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp4877dyi; Tue, 9 Jan 2024 01:51:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5GBIFn+srU4qj9o+0cvOj8NQuI8CO/OaycGQsZvlxEzF0TlSQ7iq3iXUpPLZX8MwDXogV X-Received: by 2002:a05:6214:21ef:b0:681:9f8:845f with SMTP id p15-20020a05621421ef00b0068109f8845fmr2286910qvj.101.1704793888327; Tue, 09 Jan 2024 01:51:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704793888; cv=pass; d=google.com; s=arc-20160816; b=qeIRxlaAcoSdX5XBeBfn3QmA6uhXQDR1SHaVEVMkrAMM8vOIAehNJUfoV2htNvqfyK rxE/Xh2Pp/YMq8JgnDtO80X1ixI0q7Jnu8gDAmf0HPsgWPJm04EHJgw/11zwKP62n8Gu 3mudubqPnLaCNkxLi6hwrsJpVTB/1Fz+L5fsuBesP511YoJAGJ+nItrpveFtaJZxsQSi /tkYTshjGVVZmSNupbRbfOb7Gv/lMRS1uONDfoF/qyPqce/NRpuoutHUpp2QuegUmSS+ JQZTX0WmpdnXciMDVsE0EdGqz7Xve9nOrtNEDyFo1Eh/sN1tQrwOPe3yf2bRzD91JzhR mjDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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 :arc-filter:dmarc-filter:delivered-to; bh=bhz5utQZgBsTxN+dXdQw/sbLtQYzn3QpIRe7u0pbDDk=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=l1xNLnNk2OxlZ7x1j2/4Q5XmXdo3rodyYTe93YH1r3m+00M+S4DZ6Ac86bKbsEWg1X xJcN+YPMu1GtMvl/kb/NQ9VLiuZvbk5vUvbMI10lYphM3C2mcya9bs4suhXd7xxpWWN6 LoeWn5wwR6Y92aseHnn3XCxYtE70nEcooGjmqwLx/aIeWsKI457PgFe/ENYFDX3BhjqG PAaoS1Ydq5Dvto7DcLO6rLBKg6l2gIfdKmYW+ki5Rcxpx+yUmd+K/F50TX/xv5KrEMa5 UBHnS4BbXaiDj5cbT43CEYrei0hQDfbjaUIClU5Mvmby7UnApgswVYhLzS42vrt5Pwcn sLNg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=iOY6dklu; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a8-20020a0ce388000000b0067f7155921csi1880531qvl.285.2024.01.09.01.51.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:51:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=iOY6dklu; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E02D385801D for ; Tue, 9 Jan 2024 09:51:28 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787605956359480972 X-GMAIL-MSGID: 1787605956359480972 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);