public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alex Coplan <acoplan@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/ARM/heads/morello)] cp: Allow static const __intcap data members
Date: Tue,  4 Oct 2022 10:03:38 +0000 (GMT)	[thread overview]
Message-ID: <20221004100338.656C43857343@sourceware.org> (raw)

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

commit a36d6ba058469dfe12fc1f471763b1fa1b57c1e4
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Mon Sep 26 11:26:05 2022 +0100

    cp: Allow static const __intcap data members
    
    We'd missed updating cp/decl.c:check_static_variable_definition to
    handle members of __intcap type.
    
    gcc/cp/ChangeLog:
    
            * decl.c (check_static_variable_definition): Allow INTCAP_TYPE
            static members as with integral members.
    
    gcc/testsuite/ChangeLog:
    
            * g++.target/aarch64/morello/intcap-static-const-member.C: New
            test.

Diff:
---
 gcc/cp/decl.c                                                 | 11 ++++++++---
 .../g++.target/aarch64/morello/intcap-static-const-member.C   |  4 ++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 62c97d3447c..2b742b0c6c0 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10229,7 +10229,9 @@ check_static_variable_definition (tree decl, tree type)
       && (DECL_DECLARED_CONSTEXPR_P (decl)
 	  || DECL_VAR_DECLARED_INLINE_P (decl)))
     ;
-  else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
+  else if (cxx_dialect >= cxx11
+	   && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)
+	   && !INTCAP_TYPE_P (type))
     {
       if (!COMPLETE_TYPE_P (type))
 	error_at (DECL_SOURCE_LOCATION (decl),
@@ -10250,7 +10252,9 @@ check_static_variable_definition (tree decl, tree type)
      the definition, but not both.  If it appears in the class, the
      member is a member constant.  The file-scope definition is always
      required.  */
-  else if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE)
+  else if (!ARITHMETIC_TYPE_P (type)
+	   && TREE_CODE (type) != ENUMERAL_TYPE
+	   && !INTCAP_TYPE_P (type))
     error_at (DECL_SOURCE_LOCATION (decl),
 	      "invalid in-class initialization of static data member "
 	      "of non-integral type %qT",
@@ -10260,7 +10264,8 @@ check_static_variable_definition (tree decl, tree type)
 	      "ISO C++ forbids in-class initialization of non-const "
 	      "static member %qD",
 	      decl);
-  else if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type))
+  else if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type)
+	   && !INTCAP_TYPE_P (type))
     pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
 	     "ISO C++ forbids initialization of member constant "
 	     "%qD of non-integral type %qT", decl, type);
diff --git a/gcc/testsuite/g++.target/aarch64/morello/intcap-static-const-member.C b/gcc/testsuite/g++.target/aarch64/morello/intcap-static-const-member.C
new file mode 100644
index 00000000000..4849d4bc81e
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/morello/intcap-static-const-member.C
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+struct S {
+  static const __intcap c = 42;
+};

                 reply	other threads:[~2022-10-04 10:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221004100338.656C43857343@sourceware.org \
    --to=acoplan@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).