diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-01-18 14:50:06 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-01-18 14:50:06 -0500 |
commit | 3c4a54adb2164315d18fd8980c0fc37eb3d22252 (patch) | |
tree | 628d008a2cb57b6b5bdc07d8fb34cde1056d8e91 /gcc/cp | |
parent | dad495e30135904b0d0305eab8c0ce5f838440d4 (diff) | |
download | gcc-3c4a54adb2164315d18fd8980c0fc37eb3d22252.zip gcc-3c4a54adb2164315d18fd8980c0fc37eb3d22252.tar.gz gcc-3c4a54adb2164315d18fd8980c0fc37eb3d22252.tar.bz2 |
c++: DEPENDENT_OPERATOR_TYPE as type of NTTP [PR104074]
We're incorrectly rejecting the below testcase during template argument
coercion because invalid_nontype_parm_type_p returns true for
DEPENDENT_OPERATOR_TYPE in C++17 mode.
This patch fixes this by partially rewriting invalid_nontype_parm_type_p
in terms of WILDCARD_TYPE_P, for which DEPENDENT_OPERATOR_TYPE is true,
so that the predicate handles wildcard types consistently.
PR c++/104074
gcc/cp/ChangeLog:
* pt.cc (invalid_nontype_parm_type_p): Use WILDCARD_TYPE_P so
that we return false for DEPENDENT_OPERATOR_TYPE too.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/nontype-auto20.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/pt.cc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 4a2b33e..586ad1c 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -26931,16 +26931,14 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) } return false; } - else if (TREE_CODE (type) == TYPENAME_TYPE) - return false; - else if (TREE_CODE (type) == DECLTYPE_TYPE) - return false; else if (TREE_CODE (type) == NULLPTR_TYPE) return false; - /* A bound template template parm could later be instantiated to have a valid - nontype parm type via an alias template. */ - else if (cxx_dialect >= cxx11 - && TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM) + else if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM + && cxx_dialect < cxx11) + /* Fall through; before C++11 alias templates, a bound ttp + always instantiates into a class type. */; + else if (WILDCARD_TYPE_P (type)) + /* Any other wildcard type not already handled above is allowed. */ return false; else if (TREE_CODE (type) == COMPLEX_TYPE) /* Fall through. */; |