From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id 656C43857343; Tue, 4 Oct 2022 10:03:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 656C43857343 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664877818; bh=prjbPx1dY4mmUhsybvEC4VdNzyVYOTDyv3CEQr2gkyM=; h=From:To:Subject:Date:From; b=OZewBFA/78IS2T1mWtcVm9+lCm69du92G+JoSadpcEM6qrSIbB/RMDmzYff+fqBOq wHhyEbgyT6CJqbW41S9tjsDEjMgtUZEVznUZJtkajMc9U9D6atA6JJ+c+hhDQuCXv7 8vxbp4i6NWyO/6NEyf9rS96Oo9dqRiaQdRhVxQgA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alex Coplan To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] cp: Allow static const __intcap data members X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: ee3f16b654780d3333e1b94bb373dc134ab782c3 X-Git-Newrev: a36d6ba058469dfe12fc1f471763b1fa1b57c1e4 Message-Id: <20221004100338.656C43857343@sourceware.org> Date: Tue, 4 Oct 2022 10:03:38 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a36d6ba058469dfe12fc1f471763b1fa1b57c1e4 commit a36d6ba058469dfe12fc1f471763b1fa1b57c1e4 Author: Alex Coplan 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; +};