From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 9D773388266B for ; Tue, 19 Dec 2023 14:31:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D773388266B 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 9D773388266B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996276; cv=none; b=GO7xsjn3JDifZiQp4td2KB0cB2wNGB+BCbM5AQz5fzSs3ScKRB7OtmHl9SjR4dB5S/kLFe4BsxzjiVWunwxUIZE3zyxyWeD1mjb6OyKJxTJqetjpHIOfENPS/rh4upVmY/weMwLUbujQVlf1hTztJPPjaF2Cy2b0buuG3jAFkww= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996276; c=relaxed/simple; bh=WbZwo4ZzptRAr1slTuSCWCOwcEWkuYuRz3q4TMU31Kk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DY8fTXHqVb3/GvNVWhPb21omcendU54nbL47vFxH+K0q+vuIyr+kQmSulO8bhMyf5Sz061ExVHM52pgHinozLQ/k2CMRFiZIEc0s2zP1D7Zjcy8oMZeR3SenYkHbQ4hzX65+dVmJ5Zk1okjsK5oRiod2gT7+wmmm6nT441Z53kg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33666946422so2073475f8f.1 for ; Tue, 19 Dec 2023 06:31:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702996269; x=1703601069; 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=ioD+15n+nIEodC+D2Jx21nLTwO9McKXS0j6i6M64DzA=; b=XHo8Hg3T3QfhftuMsCHa72e42fuuFG/Q0hEVGAnpuQ8yYmCgR1N1sYtPFal3ql6Jgd A9F9c4jN8RtPpxbzks64jCHkrwZiZrLLceog3qU5K0XfB2aADC85SUcWHZA703XLZcou IrchYzlty68ys2BbfZ6jip2Fvr0gfn5PM1NVB1W06yphknqyBWhipx948U032V6m8ios 135bDDhq0TeiYktErcdnv0Lg5oHleLhqwEdXPWrzS1+mttJa9j7WBj86UTKjS7LEr09V uTD2yAUodkai6cRkpg9rFv3zR7Iy8cMJnc5jmhB3OAfLrMKplJzASxjTENCEFqZ5Oq/T LJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702996269; x=1703601069; 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=ioD+15n+nIEodC+D2Jx21nLTwO9McKXS0j6i6M64DzA=; b=oOpBnFuIUqyLgEAFNxUBfA7pWjnCDB5QkVmMazv/UsQs7r/7cwXfLdbIslPGdyCWNf +FNAnm0SByFBwoT/zKYIItuTCozzy8C4HIfJPB8ywe3SFN0uqoEQSrKynW9ITEB+BxL+ JtaA4w08ewlRsGnJQRJHEety9DqidqROLNibHN8Q+JbUHDkpJEKhRF48LbV2Hkdgf8Bm iLjYvhdScDAzYhCdkbXwOw90FnpDI9wm+I6daNChhmlezySxVJymdrpsy75dBk4KycfI id/8TWwVJNaC3+Oyee4vinc7jQq1wpcWVudqpX9axdx6Y0w6VIZJvqGawjqAILtK9gCy vksw== X-Gm-Message-State: AOJu0Yxu93PnyrEXrGvUdi/GF20S5jD4hPZJwCUJb8khBQJgjbQhCtnb 7d6Ajzsqj81YaA+EToUKrH2nQFfo7PGpYv5XToU= X-Google-Smtp-Source: AGHT+IG1eKmwv2oVZDt/ULuagcqG/cYnOZlGoM/6SX+BPzGIuiVTKrVo8QXZcnkLgXFF7agJetZRrA== X-Received: by 2002:adf:e98f:0:b0:336:7798:148a with SMTP id h15-20020adfe98f000000b003367798148amr35141wrm.140.1702996269412; Tue, 19 Dec 2023 06:31:09 -0800 (PST) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:fe1e:443:c34f:edaa]) by smtp.gmail.com with ESMTPSA id d1-20020adfe841000000b00333404e9935sm8414862wrn.54.2023.12.19.06.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:31:09 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error on call with parameter of predicated subtype Date: Tue, 19 Dec 2023 15:31:08 +0100 Message-ID: <20231219143108.456179-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: From: Eric Botcazou The problem is that the predicated subtype does not inherit all the required attributes of a string subtype with a static predicate. gcc/ada/ * sem_ch3.adb (Analyze_Subtype_Declaration): Remove a short-circuit for subtypes without aspects when it comes to predicates. * sem_util.adb (Inherit_Predicate_Flags): Deal with private subtypes whose full view is an Itype. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch3.adb | 11 ++--------- gcc/ada/sem_util.adb | 7 ++++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 33d8f116bc2..a6bc8c95cd2 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6032,17 +6032,10 @@ package body Sem_Ch3 is -- If this is a subtype declaration for an actual in an instance, -- inherit static and dynamic predicates if any. - -- If declaration has no aspect specifications, inherit predicate - -- info as well. Unclear how to handle the case of both specified - -- and inherited predicates ??? Other inherited aspects, such as - -- invariants, should be OK, but the combination with later pragmas - -- may also require special merging. - if Has_Predicates (T) and then Present (Predicate_Function (T)) - and then - ((In_Instance and then not Comes_From_Source (N)) - or else No (Aspect_Specifications (N))) + and then In_Instance + and then not Comes_From_Source (N) then -- Inherit Subprograms_For_Type from the full view, if present diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 791fa7bc12e..9cff9e1be16 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -14531,11 +14531,16 @@ package body Sem_Util is -- A named subtype does not inherit the predicate function of its -- parent but an itype declared for a loop index needs the discrete -- predicate information of its parent to execute the loop properly. + -- Moreover, a named private subtype whose full view is an itype also + -- needs to inherit a predicate function because it will not be frozen. -- A non-discrete type may has a static predicate (for example True) -- but has no static_discrete_predicate. if not Only_Flags - and then Is_Itype (Subt) + and then (Is_Itype (Subt) + or else (Ekind (Subt) = E_Private_Subtype + and then Present (Full_View (Subt)) + and then Is_Itype (Full_View (Subt)))) and then Present (Predicate_Function (Par)) then Set_Subprograms_For_Type (Subt, Subprograms_For_Type (Par)); -- 2.43.0