public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/aoliva/heads/strub)] Improve integration of strub with type systems
Date: Tue, 16 Nov 2021 05:13:02 +0000 (GMT)	[thread overview]
Message-ID: <20211116051302.43EB93857404@sourceware.org> (raw)

https://gcc.gnu.org/g:cffad65eee42ae93fc6b46c119facce5e626f67d

commit cffad65eee42ae93fc6b46c119facce5e626f67d
Author: Alexandre Oliva <oliva@adacore.com>
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


             reply	other threads:[~2021-11-16  5:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16  5:13 Alexandre Oliva [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-11-16  5:13 Alexandre Oliva
2021-11-16  5:12 [gcc(refs/users/aoliva/heads/strub)] improve " Alexandre Oliva
2021-10-30 10:16 [gcc(refs/users/aoliva/heads/strub)] Improve " Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211116051302.43EB93857404@sourceware.org \
    --to=aoliva@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).