diff options
author | Joseph Myers <joseph@codesourcery.com> | 2023-02-10 00:42:47 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2023-02-10 00:42:47 +0000 |
commit | b9f8935e110c392c21460db838b4209c32f070c2 (patch) | |
tree | 329ad18e382724a5d148e1cb74b5f66fec86d69e /gcc/c/c-tree.h | |
parent | 41015797ad14bc9030a87d102e4ab1ad891345f6 (diff) | |
download | gcc-b9f8935e110c392c21460db838b4209c32f070c2.zip gcc-b9f8935e110c392c21460db838b4209c32f070c2.tar.gz gcc-b9f8935e110c392c21460db838b4209c32f070c2.tar.bz2 |
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.
Diffstat (limited to 'gcc/c/c-tree.h')
-rw-r--r-- | gcc/c/c-tree.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 00ccf87..e5eefe6 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -728,6 +728,7 @@ extern location_t c_last_sizeof_loc; extern struct c_switch *c_switch_stack; +extern bool null_pointer_constant_p (const_tree); extern bool char_type_p (tree); extern tree c_objc_common_truthvalue_conversion (location_t, tree); extern tree require_complete_type (location_t, tree); |