summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-06-22 18:19:11 -0400
committerJason Merrill <jason@redhat.com>2022-06-22 23:46:32 -0400
commitc85cea9ca165b0b771d9f913016c9dc8db46b5d7 (patch)
tree21e8a15f9547e965d2fe77bbd16ab5cd2c9cecff
parentc++: class scope function lookup [PR105908] (diff)
downloadgcc-c85cea9ca165b0b771d9f913016c9dc8db46b5d7.tar.gz
gcc-c85cea9ca165b0b771d9f913016c9dc8db46b5d7.tar.bz2
gcc-c85cea9ca165b0b771d9f913016c9dc8db46b5d7.tar.xz
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.
-rw-r--r--gcc/cp/pt.cc9
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/nontype-auto21.C20
2 files changed, 29 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 214ad8468be..67238000109 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -27892,6 +27892,15 @@ type_dependent_expression_p (tree expression)
27892 && DECL_INITIAL (expression)) 27892 && DECL_INITIAL (expression))
27893 return true; 27893 return true;
27894 27894
27895 /* Pull a FUNCTION_DECL out of a BASELINK if we can. */
27896 if (BASELINK_P (expression))
27897 {
27898 if (BASELINK_OPTYPE (expression)
27899 && dependent_type_p (BASELINK_OPTYPE (expression)))
27900 return true;
27901 expression = BASELINK_FUNCTIONS (expression);
27902 }
27903
27895 /* A function or variable template-id is type-dependent if it has any 27904 /* A function or variable template-id is type-dependent if it has any
27896 dependent template arguments. */ 27905 dependent template arguments. */
27897 if (VAR_OR_FUNCTION_DECL_P (expression) 27906 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 00000000000..376d63269cb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto21.C
@@ -0,0 +1,20 @@
1// PR c++/105964
2// { dg-do compile { target c++17 } }
3
4struct token {};
5
6struct example {};
7
8template< typename >
9struct helper
10{
11 static constexpr auto c() { return 42; }
12};
13
14struct impostor_c
15{
16 template< typename T, auto= helper< T >::c >
17 static example func();
18};
19
20example c= impostor_c::func< token >();