From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id BE89C3857704 for ; Tue, 20 Jun 2023 07:47:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE89C3857704 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3112902f785so2537964f8f.0 for ; Tue, 20 Jun 2023 00:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1687247226; x=1689839226; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Yv4ZDFUZluhqUI0ZZhn+KvjHhqPJPg1D6IGUD8c69vU=; b=T7wtj96S2qo5ZbEFfhP3GPM76zEuJNx9H48LOe/WiGuF3MA9cRS5wj1sYy5ish4F7G l2ZfWRYY08Hyeeum8GxjqH8jeLssCtK7iE2ROiA1pjemtPQEHKQ2v/un/BmkLozUXscQ dFBMlMe9yBhmQI+tdAp9w4gAm25kuH6OPSQrwO26sW0msKbC5sUa2cSSgu28odaXFrzA iJP/edPbAqr6lhpgYqhg7I8Jw7acvw+9kV91TkVeC/Y7NV8dKE6kC7g1igfeFIz3HXx4 sHkdQrfrOA8lmkItiJHD5yUtwIz31/f/HS1ScYa0NzgnmfUxpvzvfFn2Su98qxKUpJRM qLww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247226; x=1689839226; 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=Yv4ZDFUZluhqUI0ZZhn+KvjHhqPJPg1D6IGUD8c69vU=; b=N+af8zGG7sN0buWFQLxnC4EXV3wPYlbqZX7khwVyCB+y/xe6owxxwZk/onAvcNQgYY Z0NsrYH5zeQxAASmXFx+90dz0KVYq2qk2TlNvr3N4sgW1/0K8mV9z3FDyfQSKpmFfGQO E+YMR9uIJmE9QUGg9Vtm/OrGOFKSGDNGuxBLOE0cbb3CraAJP13BhMVfnH5cIJLyYZpq CcAFvOXGjgS1WunUMsjG0S/AG8YmEdldSK6Dz16CmLcweOBqnzZKL2g7uVYa9542WZTl xFlfRkk/WKwyr3yqaSL7DcAF8ydk5wpvLAAi+EcQcD9sHBAsQ186ZNDXJRsiDUNzzJto t+qA== X-Gm-Message-State: AC+VfDwtO8cQUNKMqmXppUu0Qh8ToqcH6ojUfv/AUFLfBS02vooyZHTv 4gqfYEjdjC0pHWKjFscxqP/fXoVmKtlgqY6Ad+jw1Q== X-Google-Smtp-Source: ACHHUZ5dmA8N5dptT8llabGx6wkE0TInOn98d/S3jEy3sTAg7TV6uoSIfNegUdfw0tXZDuBT9SkPZA== X-Received: by 2002:adf:f6c3:0:b0:30f:cb38:fcea with SMTP id y3-20020adff6c3000000b0030fcb38fceamr8080337wrp.35.1687247226516; Tue, 20 Jun 2023 00:47:06 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:4c16:36ea:1b76:c001]) by smtp.gmail.com with ESMTPSA id l15-20020a5d674f000000b003112f836d4esm1328436wrw.85.2023.06.20.00.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:47:05 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED] ada: Fix bug in predicate checks with address clauses Date: Tue, 20 Jun 2023 09:47:05 +0200 Message-Id: <20230620074705.1252998-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: From: Bob Duff This patch fixes a compiler bug triggered by having a type with some defaulted components, and a predicate, and an object of that type with an address clause. In this case, the compiler was crashing. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Remove predicate-check generation if there is an address clause. These are unnecessary, and cause gigi to crash. * exp_util.ads (Following_Address_Clause): Remove obsolete "???" comments. The suggested changes were done long ago. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_util.ads | 7 ------- gcc/ada/sem_ch3.adb | 11 ++++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 24065b6f7b6..02324d23db0 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -647,13 +647,6 @@ package Exp_Util is -- current declarative part to look for an address clause for the object -- being declared, and returns the clause if one is found, returns -- Empty otherwise. - -- - -- Note: this function can be costly and must be invoked with special care. - -- Possibly we could introduce a flag at parse time indicating the presence - -- of an address clause to speed this up??? - -- - -- Note: currently this function does not scan the private part, that seems - -- like a potential bug ??? type Force_Evaluation_Mode is (Relaxed, Strict); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index fb63690803b..85019dfffa5 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4690,6 +4690,16 @@ package body Sem_Ch3 is elsif No (E) and then Is_Null_Record_Type (T) then null; + -- If there is an address clause for this object, do not generate a + -- predicate check here. It will be generated later, at the freezng + -- point. It would be wrong to generate references to the object + -- here, before the address has been determined. + + elsif Has_Aspect (Id, Aspect_Address) + or else Present (Following_Address_Clause (N)) + then + null; + -- Do not generate a predicate check if the initialization expression -- is a type conversion whose target subtype statically matches the -- object's subtype because the conversion has been subjected to the @@ -4709,7 +4719,6 @@ package body Sem_Ch3 is declare Check : constant Node_Id := Make_Predicate_Check (T, New_Occurrence_Of (Id, Loc)); - begin if No (Next_Decl) then Append_To (List_Containing (N), Check); -- 2.40.0