From patchwork Thu May 25 08:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 98852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp197807vqr; Thu, 25 May 2023 01:15:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SmHyPQeD7DCIbYhcvf9XxC+0+7UQ+6Piim9AI9xGkZ1LkBHkaOwUzarFbH29QFh4Ft4bT X-Received: by 2002:aa7:c509:0:b0:508:3f06:8fd1 with SMTP id o9-20020aa7c509000000b005083f068fd1mr3668364edq.29.1685002515786; Thu, 25 May 2023 01:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685002515; cv=none; d=google.com; s=arc-20160816; b=FxBsvgMeJrh3NFNXD5inkJjj4zPFH4gdy7Ldk11ROsDvg6qDxfKv0dAGmymPnESmK2 JNhDQP4Su9WlXDkEGJB0nhLZDKSPrBO6GNutoyYglquCAd7gY0GDnZF1SJ/fjZ3dJQy0 kgTxkGwm7J+zUV4d9T3IV8MQ06AdAi3O5XJyejgX9LTg47zHhQ1hxx0x3MqQNeM4OO54 ezHibMfgfsZit5nK5+WFlZjVGhDEp59I0PJ2citqevW1CLFT7DzHEfTYz9/I0bE4d39y 64cwh9OtbETmVJPoX8NxO3VrVlDQ+yLrz/uwzGzlteIdk6QQWJ6gwfkiPImnOrwQHJxi eUsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=DTdlI+Hj7cYNSwjAETzZfnqtxVVwstjXvirzqW8D6Bk=; b=hWUIK6FN4HmeTzfsmcmeu31+09hBt56ghPBwRJQPAtD4aDsK6iKLcVjJTwfHdASXm5 80hwBNqDytvlE/DjB8w/6+pyRPaaZmm8DQrrugfG0hNACXbQj7ptE+tyBo7DaJ7ty2W7 5kJky3MF9FZ+N+ULaM6EoPMMWAsnAWd2LhjUzvIjkSJZQuUSt9tiG2tWsZuv5EfowKs0 zhUG2WcUYQW2Jj6J/r5DYMgZOJgDlCxHjVWKsz+xPM2fAzhbCVNBDOGXfjE7bPuKFw8R EYJlXyNS71Gfvb6X3XT0ZwAyoK1gFrhvMzugp8DVl26MhsJVDM510Mz/eejFzNKhbEGW 2wcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cP76Pr1D; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n24-20020aa7c698000000b0050684da86d8si629409edq.645.2023.05.25.01.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cP76Pr1D; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B94F83889E17 for ; Thu, 25 May 2023 08:10:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B94F83889E17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685002220; bh=DTdlI+Hj7cYNSwjAETzZfnqtxVVwstjXvirzqW8D6Bk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=cP76Pr1DsrLVtESj08FcyTeSOPnXpK0cwOqiRMYA/Dtcf8uvJ/8lZK6E7vj1JD3Bt WJUnjqClrMoeDTWT1E4Lt6osSW7E35oZx0KcYXP0Qb+ItYs8LbFZ9FoS5Td0gCZAJC FwNjiskWLxlBoepcAGxe+RvFO03sairraYkj4DZI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 342F7384B13D for ; Thu, 25 May 2023 08:06:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 342F7384B13D Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f6d7abe9a4so1543275e9.2 for ; Thu, 25 May 2023 01:06:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685001959; x=1687593959; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DTdlI+Hj7cYNSwjAETzZfnqtxVVwstjXvirzqW8D6Bk=; b=ZkgtFeCRstBrHDNmJzXE7qpHJRgcRa96kgy73XwIE0eynE0WDDh4c2mo+XAhkIGy+8 N3DmtO2PVGBaksYdd9TQcHICCGRX2x1q9t99p9ttsefJgt8B6ODWOLxtuELP0jacTRf8 o+eneE0OAD4pBxgFUtCXSIlVuMqsQ3ZpF/uHBOZs5UL2iY+FlDPmZfAuL0e/lyoAR5qL +CyuCWeIJYXS8TaGiKUaPLQChbPVtCUZdW7vkrJ2nzawvEoYeryt9PP3KPg+DaCDAhR4 fZjuyxeKRscowodr6HTbWy9epd6fo3sD1LZVAGSoXFH0uDtZCy2Ii8+K+2F8JGKs03rt he1g== X-Gm-Message-State: AC+VfDxdgZ2/EAsRQjhEWAiYlesWLK3cQAtF4EhZeqAu/a5/pJtMqXkq zj4Se5nHoZgeOuqxlfNmyePhavnzCGsc+Y4275iNaQ== X-Received: by 2002:a5d:5384:0:b0:30a:aecd:1091 with SMTP id d4-20020a5d5384000000b0030aaecd1091mr1738401wrv.64.1685001959069; Thu, 25 May 2023 01:05:59 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id q14-20020adff50e000000b00307acec258esm914888wro.3.2023.05.25.01.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:05:58 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED] ada: Fix crash during function return analysis Date: Thu, 25 May 2023 10:05:57 +0200 Message-Id: <20230525080557.1956782-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766853197855858329?= X-GMAIL-MSGID: =?utf-8?q?1766853197855858329?= The compiler would crash when checking type relation between the function's return type and the type of the expression used in the return statement. It would not work if the function's return type is an access type and the expression is not. gcc/ada/ * sem_ch6.adb (Analyze_Function_Return): Add missing Is_Access_Type check before accessing the Designated_Type field. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch6.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 7c90747f293..6df1c8dedd3 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -847,6 +847,7 @@ package body Sem_Ch6 is and then Serious_Errors_Detected = 0 and then Is_Access_Type (R_Type) and then Nkind (Expr) not in N_Null | N_Raise_Expression + and then Is_Access_Type (Etype (Expr)) and then Is_Interface (Designated_Type (R_Type)) and then Is_Progenitor (Designated_Type (R_Type), Designated_Type (Etype (Expr)))