diff options
author | Jason Merrill <jason@redhat.com> | 2022-06-22 18:19:11 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-06-22 23:23:01 -0400 |
commit | d29f61a3291a8c4cff0bd754fa3bb8e9399589bc (patch) | |
tree | 411de58233950f3fca46854527f13b8f905f648c /gcc | |
parent | 3104a9fa7e704d859cec46afba8b51cb1a233b40 (diff) | |
download | gcc-d29f61a3291a8c4cff0bd754fa3bb8e9399589bc.zip gcc-d29f61a3291a8c4cff0bd754fa3bb8e9399589bc.tar.gz gcc-d29f61a3291a8c4cff0bd754fa3bb8e9399589bc.tar.bz2 |
c++: dependence of baselink [PR105964]
helper<token>::c isn't dependent just because we haven't deduced its return
type yet. type_dependent_expression_p already knows how to deal with that
for bare FUNCTION_DECL, but needs to learn to look through a BASELINK.
PR c++/105964
gcc/cp/ChangeLog:
* pt.cc (type_dependent_expression_p): Look through BASELINK.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/nontype-auto21.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/pt.cc | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/nontype-auto21.C | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 28edc6a..4d1c325 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -27960,6 +27960,15 @@ type_dependent_expression_p (tree expression) && DECL_INITIAL (expression)) return true; + /* Pull a FUNCTION_DECL out of a BASELINK if we can. */ + if (BASELINK_P (expression)) + { + if (BASELINK_OPTYPE (expression) + && dependent_type_p (BASELINK_OPTYPE (expression))) + return true; + expression = BASELINK_FUNCTIONS (expression); + } + /* A function or variable template-id is type-dependent if it has any dependent template arguments. */ if (VAR_OR_FUNCTION_DECL_P (expression) diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto21.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto21.C new file mode 100644 index 0000000..376d632 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto21.C @@ -0,0 +1,20 @@ +// PR c++/105964 +// { dg-do compile { target c++17 } } + +struct token {}; + +struct example {}; + +template< typename > +struct helper +{ + static constexpr auto c() { return 42; } +}; + +struct impostor_c +{ + template< typename T, auto= helper< T >::c > + static example func(); +}; + +example c= impostor_c::func< token >(); |