Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/814836/?format=api
{ "id": 814836, "url": "http://patchwork.ozlabs.org/api/1.2/patches/814836/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20170918091222.GA37028@adacore.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.2/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170918091222.GA37028@adacore.com>", "list_archive_url": null, "date": "2017-09-18T09:12:23", "name": "[Ada] Crash on mutable record component with box initialization", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "aa5dca9bbd87ffc786c8c9d7812137d2b5f2aebf", "submitter": { "id": 64226, "url": "http://patchwork.ozlabs.org/api/1.2/people/64226/?format=api", "name": "Pierre-Marie de Rodat", "email": "derodat@adacore.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20170918091222.GA37028@adacore.com/mbox/", "series": [ { "id": 3596, "url": "http://patchwork.ozlabs.org/api/1.2/series/3596/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=3596", "date": "2017-09-18T09:12:23", "name": "[Ada] Crash on mutable record component with box initialization", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3596/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/814836/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/814836/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-return-462362-incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "mailing list gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462362-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"iTFKjJeg\"; dkim-atps=neutral", "sourceware.org; auth=none" ], "Received": [ "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwgJL3pm9z9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 19:12:34 +1000 (AEST)", "(qmail 15123 invoked by alias); 18 Sep 2017 09:12:26 -0000", "(qmail 14547 invoked by uid 89); 18 Sep 2017 09:12:25 -0000", "from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 09:12:24 +0000", "from localhost (localhost.localdomain [127.0.0.1])\tby\n\tfiltered-rock.gnat.com (Postfix) with ESMTP id 1C580560EA;\n\tMon, 18 Sep 2017 05:12:23 -0400 (EDT)", "from rock.gnat.com ([127.0.0.1])\tby localhost (rock.gnat.com\n\t[127.0.0.1]) (amavisd-new, port 10024)\twith LMTP id\n\tylVh1TlvfFNz; Mon, 18 Sep 2017 05:12:23 -0400 (EDT)", "from tron.gnat.com (tron.gnat.com [205.232.38.10])\tby\n\trock.gnat.com (Postfix) with ESMTP id 0BB45560E6;\n\tMon, 18 Sep 2017 05:12:23 -0400 (EDT)", "by tron.gnat.com (Postfix, from userid 4862)\tid 0A8F94FC;\n\tMon, 18 Sep 2017 05:12:23 -0400 (EDT)" ], "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; q=dns;\n\ts=default; b=MJkYoovG/q+0Ev96RB7QqcqzhHMDs/nXMIzyw88anj0KRxRTlT\n\txB1JZORGSBwiV3LnCnYDFBNjM6NzML4xdtOxvyeA5EkVZgc2oEebSg4NDXpmyfE5\n\tqXWAH3X/j0HJGEliYCO83FgEr/W+wkya7ABjKUIQqKz+6FdtSTtyeWUWA=", "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=QZLhUjBpcEsG/9ZKoJ1HzscDu24=; b=iTFKjJegwz63Itz3JJpz\n\tH70tUl1hNyFCpBn8jThf9B64cF4wKG1SBc8PX3ShfRjptSAx+tOaYR5XGFr342CC\n\tbkUuZF/pdKLmxmRGnbvPqYs2wgBWxZXF7pI8gnkQIVwU4F33zAU9iJpwJ9FgKLUM\n\tlF4W+T0I46CMlI/1DGPotag=", "Mailing-List": "contact gcc-patches-help@gcc.gnu.org; run by ezmlm", "Precedence": "bulk", "List-Id": "<gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>", "List-Archive": "<http://gcc.gnu.org/ml/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-help@gcc.gnu.org>", "Sender": "gcc-patches-owner@gcc.gnu.org", "X-Virus-Found": "No", "X-Spam-SWARE-Status": "No, score=-11.2 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tRCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=subsidiary", "X-HELO": "rock.gnat.com", "Date": "Mon, 18 Sep 2017 05:12:23 -0400", "From": "Pierre-Marie de Rodat <derodat@adacore.com>", "To": "gcc-patches@gcc.gnu.org", "Cc": "Ed Schonberg <schonberg@adacore.com>", "Subject": "[Ada] Crash on mutable record component with box initialization", "Message-ID": "<20170918091222.GA37028@adacore.com>", "MIME-Version": "1.0", "Content-Type": "multipart/mixed; boundary=\"ew6BAiZeqk4r7MaW\"", "Content-Disposition": "inline", "User-Agent": "Mutt/1.5.23 (2014-03-12)", "X-IsSubscribed": "yes" }, "content": "This patch fixes a compiler abort on a record declaration that includes a\nmutable record component whose default value is an aggregate that includes\na box-initialized component whose value depends on a discriminant of the\ncomponent.\n\nTested on x86_64-pc-linux-gnu, committed on trunk\n\ngcc/ada/\n\n2017-09-18 Ed Schonberg <schonberg@adacore.com>\n\n\t* exp_ch3.adb (Replace_Discriminant_References): New procedure,\n\tsubsidiary of Build_Assignment, used to handle the initialization code\n\tfor a mutable record component whose default value is an aggregate that\n\tsets the values of the discriminants of the components.\n\ngcc/testsuite/\n\n2017-09-18 Ed Schonberg <schonberg@adacore.com>\n\n\t* gnat.dg/default_variants.adb: New testcase.", "diff": "Index: exp_ch3.adb\n===================================================================\n--- exp_ch3.adb\t(revision 252907)\n+++ exp_ch3.adb\t(working copy)\n@@ -1782,6 +1782,42 @@\n Lhs : Node_Id;\n Res : List_Id;\n \n+ function Replace_Discr_Ref (N : Node_Id) return Traverse_Result;\n+ -- Analysis of the aggregate has replaced discriminants by their\n+ -- corresponding discriminals, but these are irrelevant when the\n+ -- component has a mutable type and is initialized with an aggregate.\n+ -- Instead, they must be replaced by the values supplied in the\n+ -- aggregate, that will be assigned during the expansion of the\n+ -- assignment.\n+\n+ -----------------------\n+ -- Replace_Discr_Ref --\n+ -----------------------\n+\n+ function Replace_Discr_Ref (N : Node_Id) return Traverse_Result is\n+ Val : Node_Id;\n+ begin\n+ if Is_Entity_Name (N)\n+ and then Present (Entity (N))\n+ and then Is_Formal (Entity (N))\n+ and then Present (Discriminal_Link (Entity (N)))\n+ then\n+ Val :=\n+ Make_Selected_Component (N_Loc,\n+ Prefix => New_Copy_Tree (Lhs),\n+ Selector_Name => New_Occurrence_Of\n+ (Discriminal_Link (Entity (N)), N_Loc));\n+ if Present (Val) then\n+ Rewrite (N, New_Copy_Tree (Val));\n+ end if;\n+ end if;\n+\n+ return OK;\n+ end Replace_Discr_Ref;\n+\n+ procedure Replace_Discriminant_References is\n+ new Traverse_Proc (Replace_Discr_Ref);\n+\n begin\n Lhs :=\n Make_Selected_Component (N_Loc,\n@@ -1789,6 +1825,22 @@\n Selector_Name => New_Occurrence_Of (Id, N_Loc));\n Set_Assignment_OK (Lhs);\n \n+ if Nkind (Exp) = N_Aggregate\n+ and then Has_Discriminants (Typ)\n+ and then not Is_Constrained (Base_Type (Typ))\n+ then\n+ -- The aggregate may provide new values for the discriminants\n+ -- of the component, and other components may depend on those\n+ -- discriminants. Previous analysis of those expressions have\n+ -- replaced the discriminants by the formals of the initialization\n+ -- procedure for the type, but these are irrelevant in the\n+ -- enclosing initialization procedure: those discriminant\n+ -- references must be replaced by the values provided in the\n+ -- aggregate.\n+\n+ Replace_Discriminant_References (Exp);\n+ end if;\n+\n -- Case of an access attribute applied to the current instance.\n -- Replace the reference to the type by a reference to the actual\n -- object. (Note that this handles the case of the top level of\nIndex: ../testsuite/gnat.dg/default_variants.adb\n===================================================================\n--- ../testsuite/gnat.dg/default_variants.adb\t(revision 0)\n+++ ../testsuite/gnat.dg/default_variants.adb\t(revision 0)\n@@ -0,0 +1,28 @@\n+-- { dg-do compile }\n+\n+procedure Default_Variants is\n+\n+ type Variant_Kind is (A, B);\n+\n+ function Get_Default_Value (Kind : in Variant_Kind) return Natural is (10);\n+\n+ type Variant_Type (Kind : Variant_Kind := A) is\n+ record\n+ Common : Natural := Get_Default_Value (Kind);\n+ case Kind is\n+ when A =>\n+ A_Value : Integer := Integer'First;\n+ when B =>\n+ B_Value : Natural := Natural'First;\n+ end case;\n+ end record;\n+\n+ type Containing_Type is tagged\n+ record\n+ Variant_Data : Variant_Type :=\n+ (Kind => B, Common => <>, B_Value => 1);\n+ end record;\n+\n+begin\n+ null;\n+end Default_Variants;\n", "prefixes": [ "Ada" ] }