public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] cp: Allow static const __intcap data members
@ 2022-10-04 10:03 Alex Coplan
  0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2022-10-04 10:03 UTC (permalink / raw)
  To: gcc-cvs

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;
+};

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-04 10:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 10:03 [gcc(refs/vendors/ARM/heads/morello)] cp: Allow static const __intcap data members Alex Coplan

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).