Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2194854/?format=api
{ "id": 2194854, "url": "http://patchwork.ozlabs.org/api/patches/2194854/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/aYqkAfLzsGboMpY1@jim-ghostbsd/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/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": "<aYqkAfLzsGboMpY1@jim-ghostbsd>", "list_archive_url": null, "date": "2026-02-10T03:20:33", "name": "algol68: Fix assignment of union overhead values [PR algol68/124049]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "570ef15267d5d68cfe602ba32bf7b1b79d58c4f6", "submitter": { "id": 92615, "url": "http://patchwork.ozlabs.org/api/people/92615/?format=api", "name": "James Bohl", "email": "bohlj47@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/aYqkAfLzsGboMpY1@jim-ghostbsd/mbox/", "series": [ { "id": 491595, "url": "http://patchwork.ozlabs.org/api/series/491595/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=491595", "date": "2026-02-10T03:20:33", "name": "algol68: Fix assignment of union overhead values [PR algol68/124049]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/491595/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2194854/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2194854/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=gmRkgBFx;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=gmRkgBFx", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "sourceware.org; spf=pass smtp.mailfrom=gmail.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.219.66" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f96KL1LGDz1xtr\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 10 Feb 2026 14:21:08 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 52D2E4BA23E8\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 10 Feb 2026 03:21:06 +0000 (GMT)", "from mail-qv1-f66.google.com (mail-qv1-f66.google.com\n [209.85.219.66])\n by sourceware.org (Postfix) with ESMTPS id B91B14A9F1E8\n for <gcc-patches@gcc.gnu.org>; Tue, 10 Feb 2026 03:20:36 +0000 (GMT)", "by mail-qv1-f66.google.com with SMTP id\n 6a1803df08f44-896fd2c5337so3349216d6.2\n for <gcc-patches@gcc.gnu.org>; Mon, 09 Feb 2026 19:20:36 -0800 (PST)", "from jim-ghostbsd ([67.241.23.35]) by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-506392f2e5csm89730251cf.33.2026.02.09.19.20.35\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 09 Feb 2026 19:20:35 -0800 (PST)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 52D2E4BA23E8", "OpenDKIM Filter v2.11.0 sourceware.org B91B14A9F1E8" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org B91B14A9F1E8", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org B91B14A9F1E8", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770693636; cv=none;\n b=OU/HuRW1ORyFbamKhRN90x93ARyGWPcvBCXsoXdniwgcD5v6Jffy5XB6GD6Xbj6+26/tlqmrVvrB43i7pprBkJ2eql4DquxZ9iMx41z7+vUo1XLNDI9mwsvIqj4RMGVFaivNZnB5uIF82k+gUjYnaTJwfVGYxw3A4wauRsZ/7ws=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1770693636; c=relaxed/simple;\n bh=O4svo3s6UV4Q5RwJrkz23lK1xChaHq2cvFpGvyp8+Wg=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=QXtLEJT5ktfdloNeh5ksK4uHvai0WRzbHq11i7cHGaxbdg7zikaHW9Kpk4K63105uvXPADjbS3oaD1HO3c102rahIc+lUOLpqTzu+GFA533Ikjc8auBN8+b0G14sOPbXczoOLzervKN+IQQZfnt7HfUpuMGAj/6fAGL+bhigOa8=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1770693636; x=1771298436; darn=gcc.gnu.org;\n h=content-disposition:mime-version:message-id:subject:to:from:date\n :from:to:cc:subject:date:message-id:reply-to;\n bh=NEjsZs1gbzZrjRgQHN38r95B0waZjT+NrmWM0zKpyJk=;\n b=gmRkgBFxJTPzo9QxBGQHBW1A0VQOFrXfKIvG539ekSjjvRWDT4DsPQ0f1zsTPiWXfk\n aGAHebXfH9HcXtafnqsGmykqqvp7Q0oS1GQQHJcqV2QR7yHkxgrQK6tZvk/BFWaBJnto\n 8uC8MLaD3dQ404AhFSKha7g9g0iq1HLm91ZmByfyC3msSWuLZapcj60YJ/jl0dVRxbHi\n VDhfploNWG1SlMnvLv9/RHri7bqu5fXYEJGqENbb8A3L+L73EV7wb9r6dhDDg7ZIDSol\n qCjWGiqSAcNjblCZq3W9Y/qMfhFhN1bUu2a7xtc2iCsmcic47N+ybH+4/arZG0A61TtF\n iO7A==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770693636; x=1771298436;\n h=content-disposition:mime-version:message-id:subject:to:from:date\n :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=NEjsZs1gbzZrjRgQHN38r95B0waZjT+NrmWM0zKpyJk=;\n b=p0JFMSosoJdlFzJjSCkJ34BLh5PKY9zNPiEoooFQuhw/yFHe9eNGbee9SRnH8lb0z8\n j/fpaIVxdeCBn0vCD7XA8WXOe9W+djwN0pycDl1TRZ4NGjk0fXVAIBwJ8QR+Kfuwv/Ry\n NW0fFBLGDylsklg3E69Xe14HT9qk2eg82E/T0vn3LOJadoulgPZPkPOPgOsN55UTGEqs\n 2fJ87H3TRgX+bKtLrBj0zW5UrmjgEh1lZNuhSeDak4ITF6C5gCRegefPUfIv/+LLR4gx\n XvxoOSFMC3n32Ktf8oWfL6bbfVmq35eotQODXeDuwJvbPpvV4SEEy/20ZKelaT/7eYPb\n pi/Q==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCXao7mUhRlB4zRqCwvJm0Fxcvqqt89IbdcjQMendSZb4zDuUuQgMlVzP9L2i6DPHma5/Xabj1uHEesTlg==@gcc.gnu.org", "X-Gm-Message-State": "AOJu0Yw12FNcjouNqF9WJ3F/t79otYkiWGowUP4qY6cCWhg5XvwoNr4W\n k9FRXT+S56BbO93yzV2LPYRQZ26neFlx4KfmlgP0xawHMPHh18i5yNxvMncQLSd/evA=", "X-Gm-Gg": "AZuq6aJdJ6qHjivcsiWSKEIuTBx+j9Fw8bALdLOWjjtUNvBCROJqJVjTi1iMyVHiNSj\n Cl9MatE5h4+5Bay7Yp529zZaDqZcjMObmxAPKEQ0CFpAREM+0ntfEyBGVj3d4KV6F6vg7MhBxUC\n VMAEVymGnIi9N/Zuewr17+vLDSfahPWtGrieon79F7fijJ4yE3UKEZIEJi4Luw8AxcYvEC5issg\n Ul848mJPBIe9W8IEdnnWhbpw5KfogpKf62nNwF7diD3ptIrpHa8vImCcdogIeLhxshF8nMV0bW5\n 8EBwKW/wXx/5T9sW/ky7V9NWqjdmFBj81GD+2WwOws6ZC8D/J+8ir/tfBWj7GJ1QSspPSQZw656\n G+gCkSRvINOc5M826AybR0YiqozMSi5B0f+qG9ZOYCgOyxVBKLE3LT/mFx9Cc87zJeHkl3FUbfV\n rPzuUOdbGtp++ons4=", "X-Received": "by 2002:a05:6214:e48:b0:896:f320:b189 with SMTP id\n 6a1803df08f44-896f320edd6mr111318716d6.10.1770693636016;\n Mon, 09 Feb 2026 19:20:36 -0800 (PST)", "Date": "Mon, 9 Feb 2026 22:20:33 -0500", "From": "James Bohl <bohlj47@gmail.com>", "To": "algol68@gcc.gnu.org, gcc-patches@gcc.gnu.org", "Subject": "[PATCH] algol68: Fix assignment of union overhead values [PR\n algol68/124049]", "Message-ID": "<aYqkAfLzsGboMpY1@jim-ghostbsd>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "This patch sorts union packs in the a68-parser function so that\nequivalent unions defined in different packets are assigned the same\nmapping of mode to overhead value.\n\nSigned-off-by: James Bohl <bohlj47@gmail.com>\n\ngcc/algol68/ChangeLog\n\n PR algol68/124049\n * a68.h: Prototype for a68_sort_union_packs.\n * a68-parser-modes.cc (packs_ordering): New function.\n (mode_ordering): Likewise.\n (add_mode_to_pack_sorted): Likewise.\n (sort_union_pack): Likewise.\n (a68_sort_union_packs): Likewise.\n * a68-parser.cc (a68_parser): Call a68_sort_union_packs.\n\ngcc/testsuite/ChangeLog\n\n PR algol68/124049\n * algol68/execute/modules/program-25.a68: New test.\n * algol68/execute/modules/module25a.a68: New file.\n * algol68/execute/modules/module25b.a68: New file.\n---\n gcc/algol68/a68-parser-modes.cc | 156 ++++++++++++++++++\n gcc/algol68/a68-parser.cc | 7 +\n gcc/algol68/a68.h | 1 +\n .../algol68/execute/modules/module25a.a68 | 10 ++\n .../algol68/execute/modules/module25b.a68 | 10 ++\n .../algol68/execute/modules/program-25.a68 | 9 +\n 6 files changed, 193 insertions(+)\n create mode 100644 gcc/testsuite/algol68/execute/modules/module25a.a68\n create mode 100644 gcc/testsuite/algol68/execute/modules/module25b.a68\n create mode 100644 gcc/testsuite/algol68/execute/modules/program-25.a68", "diff": "diff --git a/gcc/algol68/a68-parser-modes.cc b/gcc/algol68/a68-parser-modes.cc\nindex 5842d1325f0..09b88ad15c9 100644\n--- a/gcc/algol68/a68-parser-modes.cc\n+++ b/gcc/algol68/a68-parser-modes.cc\n@@ -32,6 +32,8 @@\n /* Few forward references. */\n \n static MOID_T *get_mode_from_declarer (NODE_T *p);\n+static int mode_ordering (MOID_T *a,MOID_T *b);\n+static PACK_T * sort_union_pack (PACK_T *u);\n \n /*\n * Mode service routines.\n@@ -198,6 +200,160 @@ a68_add_mode (MOID_T **z, int att, int dim, NODE_T *node, MOID_T *sub, PACK_T *p\n return a68_register_extra_mode (z, new_mode);\n }\n \n+/* Returns a negative value if 'a' should be ordered after 'b'.\n+ Returns a positive value if 'a' should be ordered before 'b'.\n+ Returns zero if 'a' and 'b' are equivalent. */\n+\n+static int\n+packs_ordering (PACK_T *a, PACK_T *b, bool compare_names = true)\n+{\n+ for (; a != NO_PACK && b != NO_PACK; FORWARD (a), FORWARD (b))\n+ {\n+ int order = mode_ordering (MOID (a), MOID (b));\n+ if (order != 0)\n+\treturn order;\n+ if (compare_names)\n+\t{\n+\t if (TEXT (a) != TEXT (b))\n+\t {\n+\t if (TEXT (a) == NO_TEXT)\n+\t\treturn 1;\n+\t if (TEXT (b) == NO_TEXT)\n+\t\treturn -1;\n+\t return strcmp (TEXT (a), TEXT (b));\n+\t }\n+\t}\n+ }\n+ return 0;\n+}\n+\n+/* Returns a negative value if 'a' should be ordered after 'b'.\n+ Returns a positive value if 'a' should be ordered before 'b'.\n+ Returns zero if 'a' and 'b' are equivalent. */\n+\n+static int\n+mode_ordering (MOID_T *a, MOID_T *b)\n+{\n+ if (a == b)\n+ return 0;\n+ int r = ATTRIBUTE (a) - ATTRIBUTE (b);\n+ if (r != 0)\n+ return r;\n+ r = DIM (a) - DIM (b);\n+ if (r != 0)\n+ return r;\n+ if (IS (a, STANDARD))\n+ return strcmp (NSYMBOL (NODE (a)), NSYMBOL (NODE (b)));\n+ else if (EQUIVALENT (a) == b || EQUIVALENT (b) == a)\n+ return 0;\n+ else if (a68_is_postulated_pair (A68 (top_postulate), a, b)\n+\t || a68_is_postulated_pair (A68 (top_postulate), b, a))\n+ return 0;\n+ else if (IS (a, INDICANT))\n+ {\n+ if (NODE (a) == NO_NODE)\n+\treturn 1;\n+ if (NODE (b) == NO_NODE)\n+\treturn -1;\n+ if (NODE (a) == NODE (b))\n+\treturn 0;\n+ return strcmp (NSYMBOL (NODE (a)), NSYMBOL (NODE (b)));\n+ }\n+ else if (IS (a, REF_SYMBOL))\n+ return mode_ordering (SUB (a), SUB (b));\n+ else if (IS (a, ROW_SYMBOL))\n+ return mode_ordering (SUB (a), SUB (b));\n+ else if (IS (a, FLEX_SYMBOL))\n+ return mode_ordering (SUB (a), SUB (b));\n+ else if (IS (a, STRUCT_SYMBOL))\n+ {\n+ POSTULATE_T *save = A68 (top_postulate);\n+ a68_make_postulate (&A68 (top_postulate), a, b);\n+ r = packs_ordering (PACK (a), PACK (b));\n+ a68_free_postulate_list (A68 (top_postulate), save);\n+ A68 (top_postulate) = save;\n+ return r;\n+ }\n+ else if (IS (a, UNION_SYMBOL))\n+ {\n+ PACK (a) = sort_union_pack (PACK (a));\n+ PACK (b) = sort_union_pack (PACK (b));\n+ return packs_ordering (PACK (a), PACK (b), false);\n+ }\n+ else if (IS (a, PROC_SYMBOL))\n+ {\n+ POSTULATE_T *save = A68 (top_postulate);\n+ a68_make_postulate (&A68 (top_postulate), a, b);\n+ r = mode_ordering (SUB (a), SUB (b));\n+ if (r == 0)\n+\tr = packs_ordering (PACK (a), PACK (b), false);\n+ a68_free_postulate_list (A68 (top_postulate), save);\n+ A68 (top_postulate) = save;\n+ return r;\n+ }\n+ else if (IS (a, SERIES_MODE) || IS (a, STOWED_MODE))\n+ return packs_ordering (PACK (a), PACK (b), false);\n+ return 0;\n+}\n+\n+/* Add a moid to a sorted pack, maybe with a (field) name. */\n+\n+static void\n+add_mode_to_pack_sorted (PACK_T **p, MOID_T *m, const char *text, NODE_T *node)\n+{\n+ PACK_T *z = a68_new_pack ();\n+\n+ MOID (z) = m;\n+ TEXT (z) = text;\n+ NODE (z) = node;\n+\n+ PACK_T *next = (*p);\n+ PACK_T *previous = NO_PACK;\n+ while (next != NO_PACK)\n+ {\n+ int order = mode_ordering (m,MOID (next));\n+ if (order > 0)\n+\tbreak;\n+ previous = next;\n+ FORWARD (next);\n+ }\n+ NEXT (z) = next;\n+ PREVIOUS (z) = previous;\n+\n+ if (previous == NO_PACK)\n+ *p = z;\n+ else\n+ NEXT (previous) = z;\n+\n+ if (next != NO_PACK)\n+ PREVIOUS (next) = z;\n+}\n+\n+/* Sort modes in a UNION pack. */\n+\n+static PACK_T *\n+sort_union_pack (PACK_T *u)\n+{\n+ PACK_T *z = NO_PACK;\n+ for (PACK_T *t = u; t != NO_PACK; FORWARD (t))\n+ {\n+ (void) add_mode_to_pack_sorted (&z, MOID (t), NO_TEXT, NODE (t));\n+ }\n+ return z;\n+}\n+\n+/* Sort modes in UNION packs. */\n+\n+void\n+a68_sort_union_packs (MOID_T *m)\n+{\n+ for (; m != NO_MOID; FORWARD (m))\n+ {\n+ if (IS (m, UNION_SYMBOL))\n+\tPACK (m) = sort_union_pack (PACK (m));\n+ }\n+}\n+\n /* Contract a UNION. */\n \n void\ndiff --git a/gcc/algol68/a68-parser.cc b/gcc/algol68/a68-parser.cc\nindex 885b5f524d9..4070d3fa323 100644\n--- a/gcc/algol68/a68-parser.cc\n+++ b/gcc/algol68/a68-parser.cc\n@@ -599,6 +599,13 @@ a68_parser (const char *filename)\n a68_serial_dsa (TOP_NODE (&A68_JOB));\n }\n \n+ /* Sort union packs so overhead values are assigned in the same order for\n+ equivalent unions in different packets. */\n+ if (ERROR_COUNT (&A68_JOB) == 0)\n+ {\n+ a68_sort_union_packs (TOP_MOID (&A68_JOB));\n+ }\n+\n /* Finalise syntax tree. */\n if (ERROR_COUNT (&A68_JOB) == 0)\n {\ndiff --git a/gcc/algol68/a68.h b/gcc/algol68/a68.h\nindex 2492aea6e2a..565d1a4c72f 100644\n--- a/gcc/algol68/a68.h\n+++ b/gcc/algol68/a68.h\n@@ -410,6 +410,7 @@ PACK_T *a68_absorb_union_pack (PACK_T * u);\n void a68_add_mode_to_pack (PACK_T **p, MOID_T *m, const char *text, NODE_T *node);\n void a68_add_mode_to_pack_end (PACK_T **p, MOID_T *m, const char *text, NODE_T *node);\n void a68_make_moid_list (MODULE_T *mod);\n+void a68_sort_union_packs (MOID_T* m);\n \n void a68_renumber_moids (MOID_T *p, int n);\n \ndiff --git a/gcc/testsuite/algol68/execute/modules/module25a.a68 b/gcc/testsuite/algol68/execute/modules/module25a.a68\nnew file mode 100644\nindex 00000000000..95950ba1c1c\n--- /dev/null\n+++ b/gcc/testsuite/algol68/execute/modules/module25a.a68\n@@ -0,0 +1,10 @@\n+module Module_25a =\n+def\n+ pub mode Union_a = union (int,real);\n+ pub proc union_a_string = (Union_a x) string:\n+ case x\n+ in (int): \"int\",\n+ (real): \"real\"\n+ esac;\n+ skip\n+fed\ndiff --git a/gcc/testsuite/algol68/execute/modules/module25b.a68 b/gcc/testsuite/algol68/execute/modules/module25b.a68\nnew file mode 100644\nindex 00000000000..9a05b2ae0dc\n--- /dev/null\n+++ b/gcc/testsuite/algol68/execute/modules/module25b.a68\n@@ -0,0 +1,10 @@\n+module Module_25b =\n+def\n+ pub mode Union_b = union (real,int);\n+ pub proc union_b_string = (Union_b x) string:\n+ case x\n+ in (int): \"int\",\n+ (real): \"real\"\n+ esac;\n+ skip\n+fed\ndiff --git a/gcc/testsuite/algol68/execute/modules/program-25.a68 b/gcc/testsuite/algol68/execute/modules/program-25.a68\nnew file mode 100644\nindex 00000000000..4a62a6fbcb1\n--- /dev/null\n+++ b/gcc/testsuite/algol68/execute/modules/program-25.a68\n@@ -0,0 +1,9 @@\n+{ dg-modules \"module25a module25b\" }\n+access Module_25a,Module_25b begin\n+ Union_a a = 1;\n+ Union_b b = 1;\n+ assert(union_a_string(a) = \"int\");\n+ assert(union_a_string(b) = \"int\");\n+ assert(union_b_string(a) = \"int\");\n+ assert(union_b_string(b) = \"int\")\n+end\n", "prefixes": [] }