diff options
author | Jason Merrill <jason@redhat.com> | 2019-03-18 15:35:12 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-03-18 15:35:12 -0400 |
commit | d849cfaeeaf15a30170b0fb10b4f62075a1ee58b (patch) | |
tree | c32251d20bb1609b1357de819c8f7add7824427a /gcc | |
parent | 6e3587dbbcefd4d4bdafaea0aa1cb8eb9495bd9c (diff) | |
download | gcc-d849cfaeeaf15a30170b0fb10b4f62075a1ee58b.zip gcc-d849cfaeeaf15a30170b0fb10b4f62075a1ee58b.tar.gz gcc-d849cfaeeaf15a30170b0fb10b4f62075a1ee58b.tar.bz2 |
PR c++/89761 - ICE with sizeof... in pack expansion.
In this testcase we get confused when looking at the sizeof... because the
argument pack for 'args' has been wrapped in an ARGUMENT_PACK_SELECT as part
of expanding the fold-expression. We handle this situation a bit lower down
in tsubst_pack_expansion, but that doesn't help the call to
argument_pack_element_is_expansion_p, which happens earlier.
* pt.c (argument_pack_element_is_expansion_p): Handle
ARGUMENT_PACK_SELECT.
From-SVN: r269776
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/fold10.C | 17 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a3341bd..d4dc5d7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-03-18 Jason Merrill <jason@redhat.com> + PR c++/89761 - ICE with sizeof... in pack expansion. + * pt.c (argument_pack_element_is_expansion_p): Handle + ARGUMENT_PACK_SELECT. + PR c++/89640 - GNU attributes on lambda. * parser.c (cp_parser_lambda_declarator_opt): Allow GNU attributes. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7dc6e44..0acc16d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11544,6 +11544,9 @@ make_fnparm_pack (tree spec_parm) static int argument_pack_element_is_expansion_p (tree arg_pack, int i) { + if (TREE_CODE (arg_pack) == ARGUMENT_PACK_SELECT) + /* We're being called before this happens in tsubst_pack_expansion. */ + arg_pack = ARGUMENT_PACK_SELECT_FROM_PACK (arg_pack); tree vec = ARGUMENT_PACK_ARGS (arg_pack); if (i >= TREE_VEC_LENGTH (vec)) return 0; diff --git a/gcc/testsuite/g++.dg/cpp1z/fold10.C b/gcc/testsuite/g++.dg/cpp1z/fold10.C new file mode 100644 index 0000000..1bd39a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/fold10.C @@ -0,0 +1,17 @@ +// PR c++/89761 +// { dg-do compile { target c++17 } } + +template <int...> struct seq {}; +template <bool> struct S { + template <typename Args> + constexpr static void call(Args&&...) {} +}; + +template <int ...Idx,typename ...Args> +auto foo (seq<Idx...>, Args&& ...args) { + return (S<Idx==sizeof...(args)>::call(args), ...); +} + +void bar() { + foo(seq<0,1,2>{}, 1,2,3); +} |