public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] cp: Allow const __intcap decls in constexpr context
@ 2022-11-22 22:18 Alex Coplan
0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2022-11-22 22:18 UTC (permalink / raw)
To: gcc-cvs
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");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-22 22:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 22:18 [gcc(refs/vendors/ARM/heads/morello)] cp: Allow const __intcap decls in constexpr context 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).