From patchwork Tue Nov 21 10:00:12 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: 80439 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 647673858000 for ; Tue, 21 Nov 2023 10:01:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 0F2033858286 for ; Tue, 21 Nov 2023 10:00:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F2033858286 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 0F2033858286 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700560820; cv=none; b=OF5OwcDuKBmqX///DHF8+bB5nHQFQ3n8Gd0K2gtna0DxKzQslA7hghvG5TokMN9Uw9iczXjP4LA4lAow79gsVrEguXmkmcEg8ZKepldyx69QeYdjNWlfJDkMv/P6jgOFySw5TvPy4Ouvpo4mTwP5xMr3IpYgIJ3QG+Z/wZWSrhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700560820; c=relaxed/simple; bh=NsEDQJDoFMR6rgBE/fjIjVLaCqQZH/yF0Dec8gWbNhw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EIfRlxbCb9siCRFPOhsQeL9podIDKfd+4dzCbd0V0irDdx/WBP4WujtDeb1RCoDgz+irKFmlC328aZfS+ciTGzHtkzrRqq8Qei30JhNeX9FEIn41tUd6Eii2nG5xVRWs6JnFDZpPmv4HFG/IUN/xcZwkuLkj6uT6Tabyc+w6mQA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-332c82400a5so1236952f8f.0 for ; Tue, 21 Nov 2023 02:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1700560818; x=1701165618; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=13aRArNqwgeIEJ4Jv9tg7UvuVjH2ZKSroq2CwXeWlRA=; b=U39pny9IrW/8nJFX6KPHA1y5IT1enq0tRBfkKbY2uCNb5MsXbA84ixYOk0UC1iXG2t k2m+wbYtE3bc7d4c/GDYpGS2fZVZeAqEMMgPgSTtjdBvfs6qfxWH7FhrCshAId5euLSN JnKeEp/6rxPvMFh1hqEw769ljiCLqYr/qmggy5/exnEeA4T05jgOMd31ZvxvPdDb2Le1 +9eCHsxeH4AmkGudn7q6Q31wTQBM4l9+dzsb3kua8m4c/Oys9/WB3ir9E9XSxTqWKTqE pmjolV5nNd32TfzmgFDNtJYoYF8LUg/lVN36oehfVX+da4RoM45oYIvvFVxgDw77SXeB IIIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700560818; x=1701165618; 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=13aRArNqwgeIEJ4Jv9tg7UvuVjH2ZKSroq2CwXeWlRA=; b=N5DpzPI+LJZ/OA4cy84KXNQ+aw/0jZkkcnKEgfFf+CvMv9cEE2yd8kB9vlffDiN6Vx r3HApQfYMQf2YYLN8S92o+MwIWP00L8IOuBXyyx1LUpYBZ1eVBpf4NKFfiYCLPEEqMSa hEpmfwIY0MdR317UDF31HCjCickpO4Amd6CGXhivVQPbHXmxKFJ8HGt3m9VYKxTBO9qJ uultTF/4ZZxV1XJajFm1Xk9Tv3H0YcmciWkJeHcGZe/7/UbRVxrXhGIjhjkFG/X5aQRK stqtEBNZNlOFkERCJEpX+9reKiAql+Inpwpu6BPDd41Q5LUDIwVmm0kpNexKeuBImyVK 6d8A== X-Gm-Message-State: AOJu0YyRsor2MXz6YUJOCP8CJdst1o+n7qoQuakdG/LdznktRZoCr2CL pL6bW34+pEfYr/0lWuBIANbkCs69nMyqqsQN8Ecaig== X-Google-Smtp-Source: AGHT+IHLG6Rk8VrvPhB+a6zR3252bXZQJlnr1y+EgYexbInKmG083gQw1iWcOjQLb/5qH69/tZ2nFQ== X-Received: by 2002:a05:6000:1192:b0:331:3426:4c2c with SMTP id g18-20020a056000119200b0033134264c2cmr6435823wrx.41.1700560817856; Tue, 21 Nov 2023 02:00:17 -0800 (PST) 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 q15-20020adff94f000000b0033169676e83sm14142526wrr.13.2023.11.21.02.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:00:17 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix spurious error on call with default parameter in generic package Date: Tue, 21 Nov 2023 11:00:12 +0100 Message-ID: <20231121100012.1963968-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.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+patchwork=sourceware.org@gcc.gnu.org From: Eric Botcazou This occurs when the default value is a function call returning a private type, and is caused by a bad interaction between two internal mechanisms. gcc/ada/ * sem_ch12.adb (Save_Global_References.Set_Global_Type): Beef up comment about the setting of the full view. * sem_res.adb (Resolve_Actuals.Insert_Default): Add another bypass for the case of a generic context. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 7 +++++-- gcc/ada/sem_res.adb | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index f73e1b53b0e..31fcbedf774 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -16938,8 +16938,11 @@ package body Sem_Ch12 is elsif No (Full_View (Typ)) and then Typ /= Etype (Typ) then null; - -- Otherwise mark the type for flipping and use the full view when - -- available. + -- Otherwise mark the type for flipping and set the full view on N2 + -- when available, which is necessary for Check_Private_View to swap + -- back the views in case the full declaration of Typ is visible in + -- the instantiation context. Note that this will be problematic if + -- N2 is re-analyzed later, e.g. if it's a default value in a call. else Set_Has_Private_View (N); diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 42f7c10c5c5..70a84176054 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -4017,13 +4017,21 @@ package body Sem_Res is Analyze_And_Resolve (Actval, Base_Type (Etype (Actval))); -- Resolve entities with their own type, which may differ from - -- the type of a reference in a generic context (the view - -- swapping mechanism did not anticipate the re-analysis of - -- default values in calls). + -- the type of a reference in a generic context because of the + -- trick used in Save_Global_References.Set_Global_Type to set + -- full views forcefully, which did not anticipate the need to + -- re-analyze default values in calls. elsif Is_Entity_Name (Actval) then Analyze_And_Resolve (Actval, Etype (Entity (Actval))); + -- Ditto for calls whose name is an entity, for the same reason + + elsif Nkind (Actval) = N_Function_Call + and then Is_Entity_Name (Name (Actval)) + then + Analyze_And_Resolve (Actval, Etype (Entity (Name (Actval)))); + else Analyze_And_Resolve (Actval, Etype (Actval)); end if;