Skip to content
Snippets Groups Projects
Commit 0b8693fc authored by Joseph Myers's avatar Joseph Myers
Browse files

c: Update nullptr_t comparison checks

WG14 has agreed to allow equality comparisons between pointers and
nullptr_t values that are not null pointer constants (this was
previously an exceptional case where such nullptr_t values were
handled differently from null pointer constants; other places in the
standard allowed nullptr_t values, whether or not those values are
null pointer constants, in the same contexts as null pointer
constants); see the wording at the end of N3077.  Update GCC's
implementation to match this change.

There are also changes to allow null pointer constants of integer or
pointer type to be converted to nullptr_t (by assignment, cast or
conversion as if by assignment), which I'll deal with separately.

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

gcc/c/
	* c-typeck.cc (build_binary_op): Allow comparisons between
	pointers and nullptr_t values that are not null pointer constants.

gcc/testsuite/
	* gcc.dg/c2x-constexpr-3.c: Do not expect comparison of nullptr_t
	and pointer to be disallowed.
	* gcc.dg/c2x-nullptr-1.c: Test comparisons of nullptr_t and
	pointers are allowed.
	* gcc.dg/c2x-nullptr-3.c: Do not test that comparisons of
	nullptr_t and pointers are disallowed.
parent 07c87fce
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment