From patchwork Tue Jun 2 11:19:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaius Mulley X-Patchwork-Id: 136296 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B65A4BA2E30 for ; Tue, 2 Jun 2026 11:20:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B65A4BA2E30 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=mh30RyiR X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 952A14BA2E09 for ; Tue, 2 Jun 2026 11:19:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 952A14BA2E09 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 952A14BA2E09 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780399195; cv=none; b=Kh7OLaxkYyxvU/NMGp6/34z917Qao31G6c7SscUHzR72tlS0vw5lDP9bz5wDLvJggVLsTp+KUur5dz2K5MAF5d3G8D1UhEoUfhrSsDb7tQ8QUlmQxIqtoWjppletRF6hq/+9My0kEDgclCScABE8VD6cD52nIcTqJmTSI4Yqz4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780399195; c=relaxed/simple; bh=yD680GLHiYy9N7ypB8Rley4OeywXk04skQ//I3RMg08=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qiVIJXCS+nCLYyo4VRClUVII0pZS8ASM8XdS81L1wUQrBk39KkC2KLNdalhg4Mzo7CDw6AzHdvTNMLLIvgnABYfo5Bm2VgRYEGyBzGWJsV7DhOEtC34RZHOJuNuSFSv86QFDUlrfaY/U9drKS9+aKxpCWgVeH+czazTA0hIl09c= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=mh30RyiR DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 952A14BA2E09 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so85353285e9.0 for ; Tue, 02 Jun 2026 04:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780399194; x=1781003994; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8LzjrrMv0a6pZpu5VtqCp5jGkxP37B+LVC99tYDBlP4=; b=mh30RyiRpCLBnfEE4ISY7nIcXDZRXg/lGCFVS7l5MlRHWuSjeGq6zGqs8MHfs7v1My njvgeI3/FsW82eIdkYdVd0fDnwilON93YDYiiqYB2rVBEBc3sdOPbL8KY+WbmMC88EqV EtJRwK/gnB7Iw8fIPfz8qQG6QqaT6ARGGO2M8tuC9e6rJfCoKJXRk40TuRZ/U6cTXU/K Pxhk03jNYCbr+MnHRmJYHb7c/Eelae2xr8gLo/KRliDCMw90A26KY4hmlN3AioMD156S XNdqqPs+WbxPcfhTw719SyZRfjJN+LPcv7W9pIcDSPBz5+6StqM4W7Hlqp971SAFTFUv x9pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780399194; x=1781003994; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8LzjrrMv0a6pZpu5VtqCp5jGkxP37B+LVC99tYDBlP4=; b=Tjq4vb/6hmFBo7o7gAEho+LhgYkV7o9WxrKe37nIteQEtP5bI+xXOwYBVwHCaDmK7w eePSR52PtGRyj+O/9mLSClz7FmpNPe2u1BNKMkD9noXAcoy4GlPY4gM3/QbENmLNGtDw o48TztO/bTC3XxGc/sWWRfVit4WOiBwOyysKi+ru/hTSIKsx8wBNTfx3y/2IVIIS1uSw B+sh6J7EE4nAr+GpQq3fpZCdqW4YeBlq+XbFs82P6ejDYrV0O8o2JBJXEt+PKBO5YdhP OWw0Fkqe7ev0bMVDNQS4PvMGPjxsdiq3CcNpE5hdPQXS6mL6OnMuXaYnMX83JMBEkMH9 4vwg== X-Gm-Message-State: AOJu0Yymz4QGqZyanOa7a3TLiP7h8yh+8HgkybF1AIxt6mjRi6xsnw10 T0V9lboj0LRXgv+ET97IhCLC+dx2BKqA3bypY20PMI/PxwFJ9Hlj7IbZItLCxQ== X-Gm-Gg: Acq92OGd9icRDHN+7ODZmU6CaW2fLIfySYdH9cEKxaVJSlGSqxBK4b+Me7b14D4yRA2 i/hfkzkpcHsQwpWBjBiT2wdZ70+OVzS4oysmW/Y4B72mcwV3ml3/0cy67ik8cQhvcbX5Z9/d4Qj LBctTfiUTf5k+x1Y0auRlc2N8bVcktmvIDFuDFr6Vk3TATlrcCMcfycMaekjpwS9gVzOQXk7UBd D+azpGhcPwCgxxlRM9PZlBU3VUd/+dFXaSiM4/NoboplPEaC68UYiCrUdkZiy4cJnHcsA8JRiUm YEcnorKAYV/AYcronwTJzshsJL1aYLcX5W6ZQVIz9JIn/nI+aVEF3bIAf4uyAVvEdfiJWVlf8Hw s1feyH/pHBN/A9xOhHmUU9UJZ4JLataUEWg4SXWkp0YKYL86NDTMH0uV6gb8FIUSC5W3HW0D3+e rCIJLQ8CCi6igAXg== X-Received: by 2002:a05:600c:a47:b0:490:b189:212d with SMTP id 5b1f17b1804b1-490b1892348mr6298255e9.33.1780399193528; Tue, 02 Jun 2026 04:19:53 -0700 (PDT) Received: from gawain ([82.153.63.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909c08f1bdsm156201605e9.1.2026.06.02.04.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 04:19:53 -0700 (PDT) Received: from gaius by gawain with local (Exim 4.98.2) (envelope-from ) id 1wUN9z-00000004haz-3wBr; Tue, 02 Jun 2026 12:19:51 +0100 From: Gaius Mulley To: gcc-patches@gcc.gnu.org Cc: Gaius Mulley Subject: [pushed]PR modula2/125544: ISO reallocate does not call allocate if the address is NIL Date: Tue, 2 Jun 2026 12:19:34 +0100 Message-ID: <20260602111934.1120876-1-gaiusmod2@gmail.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org This bugfix is for the ISO Storage.REALLOCATE procedure which is a GNU extension. It should behave in the same way as the PIM version by first checking whether the pointer parameter is NIL and then calling ALLOCATE. gcc/m2/ChangeLog: PR modula2/125544 * gm2-libs-iso/Storage.def (REALLOCATE): Updated comment describing new behavior. * gm2-libs-iso/Storage.mod (REALLOCATE): Check addr and call ALLOCATE if NIL else call lowerReallocate. (lowerReallocate): New procedure. Signed-off-by: Gaius Mulley --- gcc/m2/gm2-libs-iso/Storage.def | 3 ++- gcc/m2/gm2-libs-iso/Storage.mod | 33 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gcc/m2/gm2-libs-iso/Storage.def b/gcc/m2/gm2-libs-iso/Storage.def index 24bf8537896..586fb20ae67 100644 --- a/gcc/m2/gm2-libs-iso/Storage.def +++ b/gcc/m2/gm2-libs-iso/Storage.def @@ -28,7 +28,8 @@ PROCEDURE DEALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL); *) PROCEDURE REALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL); - (* Attempts to reallocate, amount of storage. Effectively it + (* If addr is NIL then ALLOCATE is called otherwise it + attempts to reallocate amount of storage. Effectively it calls ALLOCATE, copies the amount of data pointed to by addr into the new space and DEALLOCATES the addr. This procedure is a GNU extension. diff --git a/gcc/m2/gm2-libs-iso/Storage.mod b/gcc/m2/gm2-libs-iso/Storage.mod index 4f853bf2fcf..153386b96dc 100644 --- a/gcc/m2/gm2-libs-iso/Storage.mod +++ b/gcc/m2/gm2-libs-iso/Storage.mod @@ -89,17 +89,18 @@ BEGIN END DEALLOCATE ; -PROCEDURE REALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL); - (* Attempts to reallocate, amount of storage. Effectively it - calls ALLOCATE, copies the amount of data pointed to by - addr into the new space and DEALLOCATES the addr. - This procedure is a GNU extension. - *) +(* + LowerReallocate - attempts to reallocate amount of storage by + calling ALLOCATE and then coping the amount of data + pointed to by addr into the new space. + Lastly the original addr is deallocated. +*) + +PROCEDURE LowerReallocate (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL) ; VAR newa: SYSTEM.ADDRESS ; n : CARDINAL ; BEGIN - assert (initialized) ; IF NOT IsIn (storageTree, addr) THEN RAISE (storageException, ORD(pointerToUnallocatedStorage), @@ -115,6 +116,24 @@ BEGIN END ; DEALLOCATE(addr, n) ; addr := newa +END LowerReallocate ; + + +PROCEDURE REALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL); + (* If addr is NIL then ALLOCATE is called otherwise it + attempts to reallocate amount of storage. Effectively it + calls ALLOCATE, copies the amount of data pointed to by + addr into the new space and DEALLOCATES the addr. + This procedure is a GNU extension. + *) +BEGIN + assert (initialized) ; + IF addr = NIL + THEN + ALLOCATE (addr, amount) + ELSE + LowerReallocate (addr, amount) + END END REALLOCATE ;