]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Allow conversions of null pointer constants to nullptr_t
authorJoseph Myers <joseph@codesourcery.com>
Fri, 10 Feb 2023 00:42:47 +0000 (00:42 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 10 Feb 2023 00:42:47 +0000 (00:42 +0000)
commitb9f8935e110c392c21460db838b4209c32f070c2
tree329ad18e382724a5d148e1cb74b5f66fec86d69e
parent41015797ad14bc9030a87d102e4ab1ad891345f6
c: Allow conversions of null pointer constants to nullptr_t

WG14 has agreed to allow conversions (explicit and implicit) from null
pointer constants to nullptr_t; update GCC's nullptr_t implementation
to match.

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

gcc/c/
* c-convert.cc (c_convert): Allow conversion of a null pointer
constant to nullptr_t.
* c-typeck.cc (null_pointer_constant_p): Remove static.
(convert_for_assignment): Allow conversion of a null pointer
constant to nullptr_t.
(digest_init): Handle NULLPTR_TYPE among scalar conversions.
* c-tree.h (null_pointer_constant_p): Declare.

gcc/testsuite/
* gcc.dg/c2x-nullptr-1.c: Test conversion of null pointer
constants to nullptr_t.
* gcc.dg/c2x-nullptr-3.c: Do not expect errors for conversion of
null pointer constants to nullptr_t.  Do test errors for
conversion of other values to nullptr_t and for unary '+' on
nullptr_t.
gcc/c/c-convert.cc
gcc/c/c-tree.h
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/c2x-nullptr-1.c
gcc/testsuite/gcc.dg/c2x-nullptr-3.c