This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/84642] [6/7/8 Regression] ICE: segfault reading through NULL current_template_parms in synthesize_implicit_template_parm


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84642

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Author: aoliva
Date: Wed Mar 21 22:08:19 2018
New Revision: 258748

URL: https://gcc.gnu.org/viewcvs?rev=258748&root=gcc&view=rev
Log:
[PR c++/84610,84642] recover from implicit template parms gracefully

If we get a parse error during an attempted fully implicit function
template parse, and need to skip to the end of the statement or block,
we may discard the function parms scope rather than the enclosing
injected implicit template parms scope.  If we rollback a tentative
parse and try something else, we'll no longer be in a function parms
scope, but rather in a template parms scope, but we may still attempt
to synthesize implicit template parms and then fail the assert that
checks we're in a function parms scope.

This patch introduces an alternative to
finish_fully_implicit_template_p, to be used during error recovery,
that floats the implicit template parm scope to the top so that it
gets discarded as we finish and discard the failed implicit template
data, while other scopes are retained as expected.  It also clears the
implicit template parser data as we finish the template, so that it
doesn't linger on referencing discarded or used scopes and parms.

for gcc/cp/ChangeLog

        PR c++/84610
        PR c++/84642
        * parser.c (abort_fully_implicit_template_p): New.
        (cp_parser_skip_to_end_of_statement): Use it.
        (cp_parser_skip_to_end_of_block_or_statement): Likewise.
        (finish_fully_implicit_template_p): Clear
        implicit_template_parms and implicit_template_scope.

for  gcc/testsuite/ChangeLog

        PR c++/84610
        PR c++/84642
        * g++.dg/cpp0x/pr84610.C: New.
        * g++.dg/cpp0x/pr84642.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr84610.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr84642.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]