From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 43EB93857404; Tue, 16 Nov 2021 05:13:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43EB93857404 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/strub)] Improve integration of strub with type systems X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/strub X-Git-Oldrev: 59af930547b3050c7d42ac30def41ce7910eab6f X-Git-Newrev: cffad65eee42ae93fc6b46c119facce5e626f67d Message-Id: <20211116051302.43EB93857404@sourceware.org> Date: Tue, 16 Nov 2021 05:13:02 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2021 05:13:02 -0000 https://gcc.gnu.org/g:cffad65eee42ae93fc6b46c119facce5e626f67d commit cffad65eee42ae93fc6b46c119facce5e626f67d Author: Alexandre Oliva Date: Sat Oct 30 07:06:41 2021 -0300 Improve integration of strub with type systems This is a patch that complements changes to front-end and back-end, adjusting the build system to build a newly-added package, and improving handling of the strub attribute to warn on composite types. [changelog] * gcc-interface/Make-lang.in: (GNAT_ADA_OBJS): Add ada/strub.o. * gcc-interface/utils.c (handle_strub_attribute): Simplify check for pointer-to-function types. Warn when applied to composite types. TN: U611-048 Change-Id: I05a28cbe8186a33d810a9d2adadc0aa4905c5ddc Diff: --- gcc/ada/gcc-interface/Make-lang.in | 1 + gcc/ada/gcc-interface/utils.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index ab5fb72623b..ae5158a5484 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -440,6 +440,7 @@ GNAT_ADA_OBJS = \ ada/sprint.o \ ada/stand.o \ ada/stringt.o \ + ada/strub.o \ ada/style.o \ ada/styleg.o \ ada/stylesw.o \ diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index fb9efb23eb9..54fb88a1ad7 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -6616,9 +6616,7 @@ handle_strub_attribute (tree *node, tree name, { bool enable = true; - if (args - && POINTER_TYPE_P (*node) - && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (*node))) + if (args && FUNCTION_POINTER_TYPE_P (*node)) *node = TREE_TYPE (*node); if (args && FUNC_OR_METHOD_TYPE_P (*node)) @@ -6660,6 +6658,22 @@ handle_strub_attribute (tree *node, tree name, enable = false; } + /* Warn about unmet expectations that the strub attribute works like a + qualifier. ??? Could/should we extend it to the element/field types + here? */ + if (TREE_CODE (*node) == ARRAY_TYPE + || VECTOR_TYPE_P (*node) + || TREE_CODE (*node) == COMPLEX_TYPE) + warning (OPT_Wattributes, + "attribute %qE does not apply to elements" + " of non-scalar type %qT", + name, *node); + else if (RECORD_OR_UNION_TYPE_P (*node)) + warning (OPT_Wattributes, + "attribute %qE does not apply to fields" + " of aggregate type %qT", + name, *node); + /* If we see a strub-enabling attribute, and we're at the default setting, implicitly or explicitly, note that the attribute was seen, so that we can reduce the compile-time overhead to nearly zero when the strub feature is