From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id 03F1D3858C1F; Tue, 22 Nov 2022 22:18:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03F1D3858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669155527; bh=ARZJHljuIbw6IZUhodNQpObPlucCtkNb+EXZBPa3uqI=; h=From:To:Subject:Date:From; b=Pmeq+SJyzK7Nf5q+DNdUELQDZSnXl3YoNHjqe5YAZtMqfL5vJqbcAg2VrhUr2SRSY ktMTHi9dCm6/UUjD1Wldq93AX8wWmFauTEo0Shdvd1t6pfptJn4h66HSBTx9uW5xht vpmGhBzg25ndOfhuWPWxp+DAwiYACCtEIDvfZOz0= 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 const __intcap decls in constexpr context X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 605b79c1e1a10a565d42070f5069c7167fd52ec4 X-Git-Newrev: 028c38defced5a4e75cff07ae73e381c9d0fc51e Message-Id: <20221122221847.03F1D3858C1F@sourceware.org> Date: Tue, 22 Nov 2022 22:18:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:028c38defced5a4e75cff07ae73e381c9d0fc51e commit 028c38defced5a4e75cff07ae73e381c9d0fc51e Author: Alex Coplan 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");