c++: Allow subobject references in C++20.
The last new thing allowed by P1907R1: subobject addresses as template
arguments. The ABI group has discussed mangling for this; there has been
some talk of a compressed subobject mangling, but it hasn't been finalized,
so for now I'm using normal expression mangling. In order for two array
subobject references to compare as equal template arguments, the offsets
need to have the same type, so I convert them to always be the same type,
currently ptrdiff_t. Base class conversions are represented as a cast to
reference type, only if necessary to resolve an ambiguity.
This patch also updates the value of __cpp_nontype_template_args, since
the paper is fully implemented.
gcc/cp/ChangeLog:
* mangle.c (write_base_ref): New.
(write_expression): Use it for base field COMPONENT_REFs.
* pt.c (invalid_tparm_referent_p): Canonicalize the type
of array offsets. Allow subobjects.
gcc/c-family/ChangeLog:
* c-cppbuiltin.c (c_cpp_builtins): Update
__cpp_nontype_template_args for C++20.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/nontype2.C: No error in C++20.
* g++.dg/template/nontype25.C: No error in C++20.
* g++.dg/template/nontype8.C: No error in C++20.
* g++.dg/cpp2a/nontype-subob1.C: New test.
* g++.dg/cpp2a/nontype-subob2.C: New test.
* g++.dg/cpp1z/nontype3.C: Now C++17-only.
* g++.dg/cpp2a/feat-cxx2a.C: Adjust expected value.