c++: Directly fixup deferred eh-specs
authorNathan Sidwell <nathan@acm.org>
Tue, 3 Nov 2020 16:45:15 +0000 (08:45 -0800)
committerNathan Sidwell <nathan@acm.org>
Tue, 3 Nov 2020 16:49:27 +0000 (08:49 -0800)
commitcee45e49126d18fe2dc8efc83c190662cd41914d
tree055b8c78ad9ddd204792b60acb51dbfabc52a6a9
parent1c8b8efa5becb70e04216a60021b835387ffea4e
c++: Directly fixup deferred eh-specs

eh-specifiers in a class definition are complete-definition contexts,
and we sometimes need to deferr their parsing.  We create a deferred
eh specifier, which can end up persisting in the type system due to
variants being created before the deferred parse.  This causes
problems in modules handling.

This patch adds fixup_deferred_exception_variants, which directly
modifies the variants of such an eh spec once parsed.  As commented,
the general case is quite hard, so it doesn't deal with everything.
But I do catch the cases I encountered (from the std library).

gcc/cp/
* cp-tree.h (fixup_deferred_exception_variants): Declare.
* parser.c (cp_parser_class_specifier_1): Call it when
completing deferred parses rather than creating a variant.
(cp_parser_member_declaration): Move comment from ...
(cp_parser_noexcept_specification_opt): ... here.  Refactor the
deferred parse.
* tree.c (fixup_deferred_exception_variants): New.
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/tree.c