]> gcc.gnu.org Git - gcc.git/commit
c: Update checks on constexpr pointer initializers
authorJoseph Myers <joseph@codesourcery.com>
Wed, 8 Feb 2023 23:41:47 +0000 (23:41 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 8 Feb 2023 23:41:47 +0000 (23:41 +0000)
commit53678f7f794aa3ff99d9df87c02abe1caf4ec1d3
treed8b3bdb44374933e867320b3ef02e4b0d4126fc6
parent1a49390f3f6febc1f5539f76459c416dba83b4db
c: Update checks on constexpr pointer initializers

WG14 has agreed a change of the rules on constexpr pointer
initializers, so that a (constant) null value that is not a null
pointer constant is accepted in that context, rather than only
accepting null pointer constants.  (In particular, this means that a
constexpr variable of pointer type can be used to initializer another
such variable.)  Remove the null pointer constant restriction in GCC,
instead checking just whether the value is null.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-typeck.cc (check_constexpr_init): Remove argument
null_pointer_constant.  Only check pointer initializers for being
null.
(digest_init): Update calls to check_constexpr_init.

gcc/testsuite/
* gcc.dg/c2x-constexpr-1.c: Test initialization of constexpr
pointers with null values that are not null pointer constants.
* gcc.dg/c2x-constexpr-3.c: Test initialization of constexpr
pointers with non-null values, not with null values that are not
null pointer constants.
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/c2x-constexpr-1.c
gcc/testsuite/gcc.dg/c2x-constexpr-3.c
This page took 0.065573 seconds and 5 git commands to generate.