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 const __intcap decls in constexpr context
Date: Tue, 22 Nov 2022 22:18:47 +0000 (GMT)	[thread overview]
Message-ID: <20221122221847.03F1D3858C1F@sourceware.org> (raw)

https://gcc.gnu.org/g:028c38defced5a4e75cff07ae73e381c9d0fc51e

commit 028c38defced5a4e75cff07ae73e381c9d0fc51e
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Wed Nov 16 15:46:43 2022 +0000

    cp: Allow const __intcap decls in constexpr context
    
    The testcase added with the patch was getting incorrectly rejected on
    capability targets since INTCAP_TYPE constant non-volatile declarations
    were not handled by cp/decl2.c:decl_maybe_constant_var_p.

Diff:
---
 gcc/cp/decl2.c                                              | 3 ++-
 gcc/testsuite/g++.dg/cpp0x/static_assert-const-intptr-var.C | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 7d406026a20..29b9c2d9f39 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4460,7 +4460,8 @@ decl_maybe_constant_var_p (tree decl)
   if (TYPE_REF_P (type))
     /* References can be constant.  */;
   else if (CP_TYPE_CONST_NON_VOLATILE_P (type)
-	   && INTEGRAL_OR_ENUMERATION_TYPE_P (type))
+	   && (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
+	    || INTCAP_TYPE_P (type)))
     /* And const integers.  */;
   else
     return false;
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert-const-intptr-var.C b/gcc/testsuite/g++.dg/cpp0x/static_assert-const-intptr-var.C
new file mode 100644
index 00000000000..d9a0c278c67
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert-const-intptr-var.C
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++11 } }
+static const __INTPTR_TYPE__ x = 1;
+static_assert (x, "should be non-zero");

                 reply	other threads:[~2022-11-22 22:18 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=20221122221847.03F1D3858C1F@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).