[COMMITTED,49/51] ada: Add warning for too large return object in extended return statement
| Message ID | 20260602084541.3829876-49-poulhies@adacore.com |
|---|---|
| State | Committed |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> 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 52A704BA2E1C for <patchwork@sourceware.org>; Tue, 2 Jun 2026 09:33:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52A704BA2E1C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GZntjv4W X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 477144BA2E0D for <gcc-patches@gcc.gnu.org>; Tue, 2 Jun 2026 08:46:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 477144BA2E0D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 477144BA2E0D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780389997; cv=none; b=nr5SQGDiiwDFuKsgp4zKNr0G9vXoeGoovE+3Gryd/H/w172gvAydPHZ715T7FR+MNdajPdkUo/9u6PN99NgQBlGwRwta52bNElFSK4SS9W7GlS2GL0LZ4Dwdyb+5JvVJobBiQNdTOzMJv2lXs8LOtTS/1ZooHUK7NST3GkThUp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780389997; c=relaxed/simple; bh=ENnNd40jNK+OrkrEO6y49l8ou2Tbr/8MlKAz3h016i0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Bh5RHmadPm80yGyPgr+C+UWCjH8/IgMXGY4DU5ZmvSBz2dHRXgVXNCjkOvj+w3/SLFgJGo97lFR92KCn89ti4Z/adTZE5c+yH7UsvzlWwA1sENeRMYBIPRo4IIZt76gEVRFoyTfxXxPANbVW3vKDFcu3Z6EegYRAQ6m8bd3b5VM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GZntjv4W DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 477144BA2E0D Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4904fd4f6aeso93076205e9.2 for <gcc-patches@gcc.gnu.org>; Tue, 02 Jun 2026 01:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1780389996; x=1780994796; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hUzKMFJVKensTVarnhJlO+zsY+pK8iS+F6IrC/UnBzI=; b=GZntjv4WOkW9jSk2UkFeOsvjyUEvDjmUYE3//y+rAZlsvNUKb7+X68MfOENYI9MKNo +LgCRUeJ/JCXG1mpkRgDZ62dj0tW5G4VqXKFhr0UouLslImw/nVC7p6RLuiKMywDOss6 WrVvo+VauUd/BvEMnGIDTur91g8LUUnMXS9V44cEcUVOuUYW/BKhRpxLfT1SeUhOauUk MgfvQNXG3Gl8d0lWeg0u47d6goQu7sMQEloOO7KKWnU9qV/NaAemCZgQQ+KshNADw0F+ cQMhVbsJA724GcKmFdwiJjucW7e5ErE2UbZN5h4SZrMbHHvJng1gnZD+hZb3S7dKAxbq T80A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780389996; x=1780994796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hUzKMFJVKensTVarnhJlO+zsY+pK8iS+F6IrC/UnBzI=; b=iISXSOsHsiUh70uihvhllG2wR/GjtjikVdh+7WhM9t6AG7eI/SNCzdu3iVyYXwq9U3 LxpCtuKWLyN1RBKBVOHcaPDcwJBokH/YuwQiiDdiTT+gYj3EXyhV/oezjo0A4/gV4KGH 2xUygmQEn36rJ2ZX5G1vL6EIGBt4AvKQayKroPRO62EUEV+mUKszXXOr50LEJ76FcKkE 8JIgvb9xGC2Pecuf/px3Sk7SLDLzpIgpSlqvIckfXjF6kSLA7t/tpsoVI3Ru9OCej6KT +XbTVumcYTK2cQhvkiWmRMDDBLvR6LT0rrEGpy6kBWsvz57Jtt4676/8PMDU0cU0W1pO N3AQ== X-Gm-Message-State: AOJu0Yw8/VTOvdRlkb72fY9qowcH4X1h+wGeDkTUk2QizIkwWN7OaDhk G3Wl8qpZkbcLFqUYEmopILTZsFKWtJcugAMShNzeTyDh9N88ujQYU7Uvc3HCcqCGRsbrl5Ai0Ws PYWk= X-Gm-Gg: Acq92OGeAhSiax42rPbqN85g5HkIbT3vZ4w0CeTcrj3jgQWc139r/3TRi8O4vzUl+KP o8ew/wA0Yr3/mI6eb5uj91chZTEYYnpB9OJRQ0rH7jgnAFFrOuFBWO3ZhzvoC7vhS9G7Qj+bQtI kUFpQyI34iBieS/Ol8YFCQVcbQwbsBmrAuL+44Jw3FlRXY0OSMACLeZrUcamuNrltCy8bOpwKko vIlUlPHSYD1xktkM9wv7C1o8/AcNlOLO9zjDVqLhbXUUffp4zWMOV980ScWwXD8ZFbbDQUU3rWv BhgIm4NKoPDZkGC51TleJ58OKn6qIo1PeocVQ+MnVaQ2+/qapH3Dlyn+oZkqqi15cCn90N+RJbA n+c6vBxxj7d2uwlPW8gHkAshTpfK+v2qBJfuvZ+Bt5ZiYV0C4EwQaqaxnmtQnriCN4nb+0NCkum 4+AvHfpEHTg9HhHJK9km8SEGmhNA/kaCHWhlVRmqnc9FxJUJ6bBE3usGsFPsUksDJWwFTJv5W9x Xr2rZYhnzYByaEt2cLO6fPLhOLz3Ro= X-Received: by 2002:a05:600c:4714:b0:489:1c1f:35f1 with SMTP id 5b1f17b1804b1-490a290ebf2mr277659105e9.4.1780389996246; Tue, 02 Jun 2026 01:46:36 -0700 (PDT) Received: from mecano.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490ab55d39csm33907625e9.35.2026.06.02.01.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 01:46:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= <poulhies@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou <ebotcazou@adacore.com> Subject: [COMMITTED 49/51] ada: Add warning for too large return object in extended return statement Date: Tue, 2 Jun 2026 10:45:37 +0200 Message-ID: <20260602084541.3829876-49-poulhies@adacore.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260602084541.3829876-1-poulhies@adacore.com> References: <20260602084541.3829876-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_PBL, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <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>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
[COMMITTED,01/51] ada: Rename Private_Component function
|
|
Commit Message
Marc Poulhiès
June 2, 2026, 8:45 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>
The return object may be allocated directly on the return or secondary stack
by the front-end, in other words be the renaming of an allocator.
gcc/ada/ChangeLog:
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Do not
give the warning about too large a size here but...
* gcc-interface/utils2.cc (build_allocator): ...here instead.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gcc-interface/decl.cc | 6 ------
gcc/ada/gcc-interface/utils2.cc | 5 ++++-
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index cf6c37f1ca2..50a065d2dea 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -1489,12 +1489,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) false); } - /* Give a warning if the size is constant but too large. */ - if (TREE_CODE (TYPE_SIZE_UNIT (gnu_alloc_type)) == INTEGER_CST - && !valid_constant_size_p (TYPE_SIZE_UNIT (gnu_alloc_type))) - post_error ("??Storage_Error will be raised at run time!", - gnat_entity); - gnu_expr = build_allocator (gnu_alloc_type, gnu_expr, gnu_type, Empty, Empty, gnat_entity, mutable_p); diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 3604d4df761..9de47a70240 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -2731,7 +2731,10 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, /* If the size overflows, pass -1 so Storage_Error will be raised. */ if (TREE_CODE (size) == INTEGER_CST && !valid_constant_size_p (size)) - size = size_int (-1); + { + post_error ("??Storage_Error will be raised at run time!", gnat_node); + size = size_int (-1); + } storage = convert (result_type, build_call_alloc_dealloc (NULL_TREE, size, type,