]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: fix template parm count leak
authorNathan Sidwell <nathan@acm.org>
Tue, 4 Aug 2020 16:24:02 +0000 (09:24 -0700)
committerGiuliano Belinassi <giuliano.belinassi@usp.br>
Mon, 17 Aug 2020 18:07:34 +0000 (15:07 -0300)
commitd0c87fdc9be14c12532bd0334b1d8c904a77524f
tree1d66572f9491982f0ec19cd378f017ebd3dfbc55
parent2c6ee34883a5142eb538c824701ab033065477c1
c++: fix template parm count leak

I noticed that we could leak parser->num_template_parameter_lists with
erroneous specializations.  We'd increment, notice a problem and then
bail out.  This refactors cp_parser_explicit_specialization to avoid
that code path.  A couple of tests get different diagnostics because
of the fix.  pr39425 then goes to unbounded template instantiation
and exceeds the implementation limit.

gcc/cp/
* parser.c (cp_parser_explicit_specialization): Refactor
to avoid leak of num_template_parameter_lists value.
gcc/testsuite/
* g++.dg/template/pr39425.C: Adjust errors, (unbounded
template recursion).
* g++.old-deja/g++.pt/spec20.C: Remove fallout diagnostics.
gcc/cp/parser.c
gcc/testsuite/g++.dg/template/pr39425.C
gcc/testsuite/g++.old-deja/g++.pt/spec20.C