On 2/20/19 12:38 PM, Jakub Jelinek wrote:
Hi!

On the following testcase we ICE, because expand_or_defer_fn is called
multiple times on the same ctor (once from instantiation of constexpr
functions, once from c_parse_final_cleanups) and this calls maybe_clone_body
which isn't really prepared to be called multiple times.  In particular,
when the clones already have DECL_INITIAL etc., calling
start_preparsed_function on it again doesn't set cfun to non-NULL and the
code wants to store something there (but generally, it is pointless to do it
again even if it worked).  If maybe_clone_body returns true, we set
TREE_ASM_WRITTEN:
   if (maybe_clone_body (fn))
     {
       /* We don't want to process FN again, so pretend we've written
          it out, even though we haven't.  */
       TREE_ASM_WRITTEN (fn) = 1;
       /* If this is a constexpr function, keep DECL_SAVED_TREE.  */
       if (!DECL_DECLARED_CONSTEXPR_P (fn))
         DECL_SAVED_TREE (fn) = NULL_TREE;
       return false;
     }
but if it doesn't because it wants to emit the original ctor as well (can't
use aliases), then we don't set that.  This patch moves the -fsyntax-only
setting of the TREE_ASM_WRITTEN bit from c_parse_final_cleanups to
expand_or_defer_fn_1, so that if we do it once, we don't do that again.
For -fsyntax-only, I believe there is nothing further we want to do on the
cdtor.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-02-20  Jakub Jelinek  <ja...@redhat.com>

        PR c++/89403
        * decl2.c (c_parse_final_cleanups): Move TREE_ASM_WRITTEN setting
        for flag_syntax_only from here...
        * semantics.c (expand_or_defer_fn_1): ... here.

OK.

Jason

Reply via email to