From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 70F273851ABF for ; Mon, 12 Sep 2022 08:19:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70F273851ABF 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-x42e.google.com with SMTP id d2so14085455wrn.1 for ; Mon, 12 Sep 2022 01:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=lKPkripIGVPLNRIxfhSth04XzUqZf8jklX4iMzlA4vI=; b=MY7jQOCB5F0qvN3OmjUgxrtdQzrOBTYlkxFQd9Q2KLyvy0ERlZCia3fRh2CuceTdvx kgJoL7lTz8FB8BIe+I2F7BB7UAz5TNN550ey5j1IAAgL7wwMFAsFIeoAwzduoBz46qEB XAjpQSUxsjKobok0w8hkzUb0N8Lm9sr+VcjWAJA0v6mOXbHoe0u0f2m2g7B7LlQj4GBs 7F7ukJJx2i1UunQZPIXHo+ISnoudhtfpWPdQuvmfVBrfX6MpyB1mgyibArD+HXjO7fvc 5F0OlLb8BxYatE9fW0gGBwiH2FpqopaCBEfiEncHTOfhFXIGyYMlph0QiSmAn7jLHBRn y1MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=lKPkripIGVPLNRIxfhSth04XzUqZf8jklX4iMzlA4vI=; b=tdFIx9wmiurfDQWj1Cx1Ycys/Jsj1Sda7Y3YspWWuiFKLDdk9w9nY15OHg2RKGoTtr EA0wkv8Vglmkc6mM5axZ7bMQ5qTCbZnVj2epuU9T9SP8ZSAu+lobPbJVn0hl069geWpZ ebgE0spfGxVjyjcQL8zpa6XxmEjuInCCdlzMOck61ZgX60h5t/0SGKO7ISlgWeUurqBp nKI7NbQAOBE9jg/UY2H7+d0A3jEFEAXoymtkbIX34qhNoub9t/2pExzUyiOu3rFhSQY4 KmNB9OHTahTLeP3UaG8cvoJbYmknn38ETjWj5Uhv6V7I3xdKLq3qzsX+nqdAKaBbLou+ uCRg== X-Gm-Message-State: ACgBeo1fFZrf8l7GDbirw5+HEeg6OL/op4yEP6sneKIcon+DTV2CUnsh xfAJFXgaFuedll+hx+4oIIqtaAvi6Yq3oA== X-Google-Smtp-Source: AA6agR58cG9zYpD0W6zJAvlI0FQ/xi/gooRQLQfWNwkdLduOWfmE18xCjB305FhPSzXnVWO9hLJFdQ== X-Received: by 2002:a5d:5310:0:b0:22a:3960:b405 with SMTP id e16-20020a5d5310000000b0022a3960b405mr9062795wrv.235.1662970764122; Mon, 12 Sep 2022 01:19:24 -0700 (PDT) Received: from poulhies-Precision-5550 (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id l4-20020a05600c47c400b003a541d893desm8518278wmo.38.2022.09.12.01.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:19:23 -0700 (PDT) Date: Mon, 12 Sep 2022 10:19:23 +0200 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [Ada] bugbox referencing INOX prefixed view of primitive op of modular type Message-ID: <20220912081923.GA1512890@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline X-Spam-Status: No, score=-12.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: --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The -gnatX switch enables naming a prefixed view of a subprogram with an untagged prefix. Compiling such a reference where the prefix is of a modular type could result in an internal compiler error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Avoid initializing the local variable Comp if the variable is not going to be subsequently referenced. This is a correctness issue because the call to First_Entity can fail. --FCuugMFkClbJLl1L Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5187,7 +5187,16 @@ package body Sem_Ch4 is and then not Is_Derived_Type (Prefix_Type) and then Is_Entity_Name (Name); - Comp := First_Entity (Type_To_Use); + -- Avoid initializing Comp if that initialization is not needed + -- (and, more importantly, if the call to First_Entity could fail). + + if Has_Discriminants (Type_To_Use) + or else Is_Record_Type (Type_To_Use) + or else Is_Private_Type (Type_To_Use) + or else Is_Concurrent_Type (Type_To_Use) + then + Comp := First_Entity (Type_To_Use); + end if; -- If the selector has an original discriminant, the node appears in -- an instance. Replace the discriminant with the corresponding one --FCuugMFkClbJLl1L--