]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constness of decltype of NTTP object [PR99631]
authorPatrick Palka <ppalka@redhat.com>
Tue, 19 Sep 2023 12:21:05 +0000 (08:21 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 19 Sep 2023 12:21:05 +0000 (08:21 -0400)
commitddd064e3571c4a9e6258c75eba65585a07367712
tree2be793bda1a76e2655f7487acf8f9c7bfe9344e1
parent131c1df8d901385c8622aa067c5890458005d1a9
c++: constness of decltype of NTTP object [PR99631]

This corrects resolving decltype of a (class) NTTP object as per
[dcl.type.decltype]/1.2 and [temp.param]/6 in the type-dependent case.

Note that in the non-dependent case we resolve the decltype ahead of
time, in which case finish_decltype_type drops the const VIEW_CONVERT_EXPR
wrapper around the TEMPLATE_PARM_INDEX, and the latter has the desired
non-const type.

In the type-dependent case, at instantiation time tsubst drops the
VIEW_CONVERT_EXPR since the substituted NTTP is the already-const object
created by get_template_parm_object.  So in this case finish_decltype_type
sees the const object, which this patch now adds special handling for.

PR c++/99631

gcc/cp/ChangeLog:

* semantics.cc (finish_decltype_type): For an NTTP object,
return its type modulo cv-quals.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class60.C: New test.
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/cpp2a/nontype-class60.C [new file with mode: 0644]