From: Jason Merrill Date: Sat, 19 May 2018 22:57:53 +0000 (-0400) Subject: Avoid ICE on unsupported use of __integer_pack. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4b950a6d7c620834d77a63ffe2ee9704df0e4cdc;p=gcc.git Avoid ICE on unsupported use of __integer_pack. * pt.c (tsubst_pack_expansion): Sorry rather than abort on __integer_pack as subexpression of pattern. From-SVN: r260404 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e4fcffca05b..92039fa8e9a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-05-19 Jason Merrill + + * pt.c (tsubst_pack_expansion): Sorry rather than abort + on __integer_pack as subexpression of pattern. + 2018-05-18 Jason Merrill PR c++/58407 - deprecated implicit copy ops. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1e4204043bb..81de633b1ee 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12067,8 +12067,13 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, } else if (builtin_pack_call_p (parm_pack)) { - /* ??? Support use in other patterns. */ - gcc_assert (parm_pack == pattern); + if (parm_pack != pattern) + { + if (complain & tf_error) + sorry ("%qE is not the entire pattern of the pack expansion", + parm_pack); + return error_mark_node; + } return expand_builtin_pack_call (parm_pack, args, complain, in_decl); } diff --git a/gcc/testsuite/g++.dg/ext/integer-pack4.C b/gcc/testsuite/g++.dg/ext/integer-pack4.C new file mode 100644 index 00000000000..6e5125baab0 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/integer-pack4.C @@ -0,0 +1,10 @@ +// { dg-additional-options -std=c++17 } + +template int f() { return (Ns + ...); } +template int g() { + return f<__integer_pack(N)...>(); // Fine. +} +template int h() { + return f<(2*__integer_pack(N))...>(); // { dg-bogus "sorry" "" { xfail *-*-* } } +} +int main() { return g<3>()+h<3>(); }