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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:25fdd0d6df44044a8b505e6fcd07270e2e279b06

commit r11-7065-g25fdd0d6df44044a8b505e6fcd07270e2e279b06
Author: Marek Polacek <pola...@redhat.com>
Date:   Mon Feb 1 23:30:05 2021 -0500

    c++: ICE with late parsing of noexcept in nested class [PR98899]

    Here we crash with a noexcept-specifier in a nested template class,
    because my handling of such deferred-parse noexcept-specifiers was
    gronked when we need to instantiate a DEFERRED_PARSE before it was
    actually parsed at the end of the outermost class.

    In

      struct S {
        template<class> struct B {
          B() noexcept(noexcept(x));
          int x;
        };
        struct A : B<int> {
          A() : B() {}
        };
      };

    we call complete_type for B<int> which triggers tsubsting S::B<int>::B()
    whose noexcept-specifier still contains a DEFERRED_PARSE.  The trick is
    to stash such noexcept-specifiers into DEFPARSE_INSTANTIATIONS so that
    we can replace it later when we've finally parsed all deferred
    noexcept-specifiers.

    In passing, fix missing usage of UNPARSED_NOEXCEPT_SPEC_P.

    gcc/cp/ChangeLog:

            PR c++/98899
            * parser.c (cp_parser_class_specifier_1): Use any possible
            DEFPARSE_INSTANTIATIONS to update DEFERRED_NOEXCEPT_PATTERN.
            (cp_parser_save_noexcept): Initialize DEFPARSE_INSTANTIATIONS.
            * pt.c (tsubst_exception_specification): Stash new_specs into
            DEFPARSE_INSTANTIATIONS.
            * tree.c (fixup_deferred_exception_variants): Use
            UNPARSED_NOEXCEPT_SPEC_P.

    gcc/testsuite/ChangeLog:

            PR c++/98899
            * g++.dg/cpp0x/noexcept65.C: New test.

Reply via email to