From: Jason Merrill Date: Mon, 26 Mar 2018 14:37:50 +0000 (-0400) Subject: PR c++/85049 - ICE with __integer_pack. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ddd5c5b7c66a934bb54e4acdddad08a4191d6043;p=gcc.git PR c++/85049 - ICE with __integer_pack. * pt.c (unify_pack_expansion): Don't try to deduce generated packs. * cp-tree.h (TEMPLATE_PARM_P): New. From-SVN: r258856 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 09cc7dac812..011b24e9068 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-26 Jason Merrill + + PR c++/85049 - ICE with __integer_pack. + * pt.c (unify_pack_expansion): Don't try to deduce generated packs. + * cp-tree.h (TEMPLATE_PARM_P): New. + 2018-03-23 Jason Merrill PR c++/78489 - wrong SFINAE behavior. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c8f4bc43fa3..db79338035d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4554,6 +4554,12 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) || TREE_CODE (NODE) == TYPE_DECL \ || TREE_CODE (NODE) == TEMPLATE_DECL)) +/* Nonzero for a raw template parameter node. */ +#define TEMPLATE_PARM_P(NODE) \ + (TREE_CODE (NODE) == TEMPLATE_TYPE_PARM \ + || TREE_CODE (NODE) == TEMPLATE_TEMPLATE_PARM \ + || TREE_CODE (NODE) == TEMPLATE_PARM_INDEX) + /* Mark NODE as a template parameter. */ #define SET_DECL_TEMPLATE_PARM_P(NODE) \ (DECL_LANG_FLAG_0 (NODE) = 1) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9cf03f45e24..d6cce3e67da 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -20645,6 +20645,11 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, tree parm_pack = TREE_VALUE (pack); int idx, level; + /* Only template parameter packs can be deduced, not e.g. function + parameter packs or __bases or __integer_pack. */ + if (!TEMPLATE_PARM_P (parm_pack)) + continue; + /* Determine the index and level of this parameter pack. */ template_parm_level_and_index (parm_pack, &level, &idx); if (level < levels) diff --git a/gcc/testsuite/g++.dg/ext/integer-pack3.C b/gcc/testsuite/g++.dg/ext/integer-pack3.C new file mode 100644 index 00000000000..d3ed1363016 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/integer-pack3.C @@ -0,0 +1,21 @@ +// PR c++/85049 +// { dg-do compile { target c++11 } } + +typedef __SIZE_TYPE__ size_t; +template +struct integer_sequence +{ + typedef _Tp value_type; + static constexpr size_t size() noexcept { return sizeof...(_Idx); } +}; +template +using make_integer_sequence = integer_sequence<_Tp, __integer_pack(_Num)...>; +template +using make_index_sequence = make_integer_sequence; +template +using index_sequence_for = make_index_sequence; +template +struct tuple {}; +template +int get(tuple, Ts...>); +int x = get(tuple>{});