aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-12-16 13:22:17 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-12-16 13:22:17 -0500
commit65016251f649b17274bda3628c02df1cb154220a (patch)
tree135523b5c2a7da7e27690fbb0869927f5718cda9 /gcc
parentde67c4c37913cb4f30cc0d5163665ab8419ac2ed (diff)
downloadgcc-65016251f649b17274bda3628c02df1cb154220a.zip
gcc-65016251f649b17274bda3628c02df1cb154220a.tar.gz
gcc-65016251f649b17274bda3628c02df1cb154220a.tar.bz2
re PR c++/63628 ([c++1y] cannot use decltype on captured arg-pack)
PR c++/63628 * pt.c (tsubst_pack_expansion): Also make dummy decls if retrieve_local_specialization fails. From-SVN: r231713
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c15
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic3.C15
3 files changed, 30 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a3a73a3..7517792 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-16 Jason Merrill <jason@redhat.com>
+
+ PR c++/63628
+ * pt.c (tsubst_pack_expansion): Also make dummy decls if
+ retrieve_local_specialization fails.
+
2015-12-16 David Malcolm <dmalcolm@redhat.com>
* parser.c (cp_lexer_peek_conflict_marker): New function.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8a39ca4..2c2da11 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10803,12 +10803,16 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
if (PACK_EXPANSION_LOCAL_P (t) || CONSTRAINT_VAR_P (parm_pack))
arg_pack = retrieve_local_specialization (parm_pack);
else
+ /* We can't rely on local_specializations for a parameter
+ name used later in a function declaration (such as in a
+ late-specified return type). Even if it exists, it might
+ have the wrong value for a recursive call. */
+ need_local_specializations = true;
+
+ if (!arg_pack)
{
- /* We can't rely on local_specializations for a parameter
- name used later in a function declaration (such as in a
- late-specified return type). Even if it exists, it might
- have the wrong value for a recursive call. Just make a
- dummy decl, since it's only used for its type. */
+ /* This parameter pack was used in an unevaluated context. Just
+ make a dummy decl, since it's only used for its type. */
arg_pack = tsubst_decl (parm_pack, args, complain);
if (arg_pack && DECL_PACK_P (arg_pack))
/* Partial instantiation of the parm_pack, we can't build
@@ -10816,7 +10820,6 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
arg_pack = NULL_TREE;
else
arg_pack = make_fnparm_pack (arg_pack);
- need_local_specializations = true;
}
}
else if (TREE_CODE (parm_pack) == FIELD_DECL)
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic3.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic3.C
new file mode 100644
index 0000000..9b3455a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic3.C
@@ -0,0 +1,15 @@
+// PR c++/63628
+// { dg-do compile { target c++14 } }
+
+auto const pack = [](auto&&... t)
+{
+ return [&](auto&& f)->decltype(auto)
+ {
+ return f(static_cast<decltype(t)>(t)...);
+ };
+};
+
+int main(int argc, char** argv) {
+ pack(1)([](int){});
+ return 0;
+}