From patchwork Wed Aug 14 09:53:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1146893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506905-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kNJh5duY"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 467lKj2Sf0z9sDQ for ; Wed, 14 Aug 2019 19:54:17 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=b+NZxU+Yp6qdJoV/Z4Fi9l4Eeylf73MjNaeN1dXJRi7kQFDRyb tqoLZBucFgW4K5y0BnoVtsLXGmfcNSr2pJ02eO0FNH6JChj+vFHN8xKTcCWQ1YrN GFYTSVqeePYsuFEdUwL7cJZ4FzN1+Xm+E+D3GS1UOBuhC7NB5FF9MSOgg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=NYPUIKoRtycouBQiv46oc38MVpE=; b=kNJh5duYeddqZVLvFbk2 Cu0vrCTYZL1dXurxLUNnCj2cWQVxFCattrgYIJHswQHsI7fiQ08SmXYVfEXW42zL Mj4oo1hHRmm4UcCUgcE/zeP+HHjTuQ8cJ0WdKvB5Q1UfirlQzv8LRwEQl0S8gsMs WkTs0ZSlCLoz1eN9ZjOhOPM= Received: (qmail 73450 invoked by alias); 14 Aug 2019 09:53:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 73412 invoked by uid 89); 14 Aug 2019 09:53:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Exp_Aggr, Typ X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Aug 2019 09:53:16 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3E42756109; Wed, 14 Aug 2019 05:53:13 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id n42hIiwu11L4; Wed, 14 Aug 2019 05:53:13 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 2260311626C; Wed, 14 Aug 2019 05:53:13 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 1F6296CC; Wed, 14 Aug 2019 05:53:13 -0400 (EDT) Date: Wed, 14 Aug 2019 05:53:13 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Spurious error in discriminated aggregate Message-ID: <20190814095312.GA52210@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This patch fixes a bug in which a spurious error is given on an aggregate of a type derived from a subtype with a constrained discriminant. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-14 Bob Duff gcc/ada/ * exp_aggr.adb (Init_Hidden_Discriminants): Avoid processing the wrong discriminant, which could be of the wrong type. gcc/testsuite/ * gnat.dg/discr57.adb: New testcase. --- gcc/ada/exp_aggr.adb +++ gcc/ada/exp_aggr.adb @@ -2689,8 +2689,10 @@ package body Exp_Aggr is Discr_Constr := First_Elmt (Stored_Constraint (Full_View (Base_Typ))); + -- Otherwise, no discriminant to process + else - Discr_Constr := First_Elmt (Stored_Constraint (Typ)); + Discr_Constr := No_Elmt; end if; while Present (Discr) and then Present (Discr_Constr) loop --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/discr57.adb @@ -0,0 +1,17 @@ +-- { dg-do compile } + +procedure Discr57 is + + type T1(Scalar : Boolean) is abstract tagged null record; + + subtype S1 is T1 (Scalar => False); + + type T2(Lower_Bound : Natural) is new + S1 with null record; + + Obj : constant T2 := + (Lower_Bound => 123); + +begin + null; +end Discr57;