From e5f47972f63702afba99c291b81ff5a61506699f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Jun 2020 08:25:50 +0200 Subject: Work around GCC bug 86441 --- odb/semantics/class.cxx | 36 ++++++++++++++++++++++++++++++++---- odb/validator.cxx | 3 +++ 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'odb') diff --git a/odb/semantics/class.cxx b/odb/semantics/class.cxx index c03de92..acecb35 100644 --- a/odb/semantics/class.cxx +++ b/odb/semantics/class.cxx @@ -25,11 +25,39 @@ namespace semantics { tree t (tree_node ()); - // TYPE_HAS_DEFAULT_CONSTRUCTOR() returns true if we have a - // deleted default ctor. locate_ctor(), on the other hand, - // returns NULL_TREE in this case. + // TYPE_HAS_DEFAULT_CONSTRUCTOR() returns true if we have a deleted + // default ctor. locate_ctor(), on the other hand, returns NULL_TREE in + // this case. // - return TYPE_HAS_DEFAULT_CONSTRUCTOR (t) && locate_ctor (t) != NULL_TREE; + if (TYPE_HAS_DEFAULT_CONSTRUCTOR (t)) + { +#if BUILDING_GCC_MAJOR >= 8 + + // Work around GCC bug 86441. Essentially, we should not trigger an + // instantiation or completion of the default ctor. As a result, we will + // assume that if we have a lazy default ctor, it is not implicitly + // deleted. + // + if (CLASSTYPE_LAZY_DEFAULT_CTOR (t)) + return true; + + for (ovl_iterator i (CLASSTYPE_CONSTRUCTORS (t)); i; ++i) + { + tree f (*i); + + if (TREE_CODE (f) == FUNCTION_DECL && DECL_DELETED_FN (f)) + continue; + + if (default_ctor_p (f)) + return true; + } +#else + return locate_ctor (t) != NULL_TREE; +#endif + + } + + return false; } bool class_:: diff --git a/odb/validator.cxx b/odb/validator.cxx index 9c20714..bf9aa6b 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -1655,6 +1655,9 @@ namespace // temporarily redirect diagnostics to /dev/null, which is // where asm_out_file points to (see plugin.cxx). // + // Needless to say, this is very hacky and we should quickly fail + // (as we do below) if there were errors. + // int ec (errorcount); FILE* s (global_dc->printer->buffer->stream); global_dc->printer->buffer->stream = asm_out_file; -- cgit v1.1