From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id 67AE2381DCE1; Tue, 17 Mar 2020 20:22:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67AE2381DCE1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584476578; bh=ABrmrhraZBrnkUf4IvlhrAIN7HaKA8KENsYd++M+edI=; h=From:To:Subject:Date:From; b=pzZ4zvEE7cCN2KMzEcrUxeZuV3tn/snRkHF9Mk5b+YnVfhbJm79OrcHJqdoDOfqFE 6OsyelEGUQNBoQBpOm+Ge43vlbfLRCq7zu8rI+0es23k3j9oNN6nfU+29was/hTZb0 J9s4pUmzkPUtA1EYQWvLsvHUN3/wPCvvQj5DTqoc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/c++-modules] Instantiated noexcept specifications X-Act-Checkin: gcc X-Git-Author: Nathan Sidwell X-Git-Refname: refs/heads/devel/c++-modules X-Git-Oldrev: 71af6e7ca37bcc3e0ddd331fe35c7c1c874dec48 X-Git-Newrev: 736b82e061f5fb73f5f835253a0d74c2dceaafcb Message-Id: <20200317202258.67AE2381DCE1@sourceware.org> Date: Tue, 17 Mar 2020 20:22:58 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2020 20:22:58 -0000 https://gcc.gnu.org/g:736b82e061f5fb73f5f835253a0d74c2dceaafcb commit 736b82e061f5fb73f5f835253a0d74c2dceaafcb Author: Nathan Sidwell Date: Tue Mar 17 13:13:31 2020 -0700 Instantiated noexcept specifications gcc/cp/ * module.cc (trees_in::is_matching_decl): Propagate instantiated noexcept specifications. gcc/testsuite/ * g++.dg/modules/except-3{,_[ab]}.[hHC]: New. Diff: --- ChangeLog.modules | 6 ++++++ gcc/cp/module.cc | 33 +++++++++++++++++++++++++++++++ gcc/testsuite/g++.dg/modules/except-3.h | 24 ++++++++++++++++++++++ gcc/testsuite/g++.dg/modules/except-3_a.H | 6 ++++++ gcc/testsuite/g++.dg/modules/except-3_b.C | 7 +++++++ 5 files changed, 76 insertions(+) diff --git a/ChangeLog.modules b/ChangeLog.modules index 65668f211be..fa4d5346de5 100644 --- a/ChangeLog.modules +++ b/ChangeLog.modules @@ -1,5 +1,11 @@ 2020-03-17 Nathan Sidwell + gcc/cp/ + * module.cc (trees_in::is_matching_decl): Propagate instantiated + noexcept specifications. + gcc/testsuite/ + * g++.dg/modules/except-3{,_[ab]}.[hHC]: New. + gcc/cp/ * module.cc (lazy_snum, recursive_lazy): New. (module_state::read_language): Set lazy_snum. diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index efab2cf88a0..60a7f2583fd 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -10430,6 +10430,39 @@ trees_in::is_matching_decl (tree existing, tree decl, tree inner) return false; } + if (TREE_CODE (decl) == FUNCTION_DECL) + { + /* If EXISTING has an undeduced or uninstantiated exception + specification, but DECL does not, propagate the exception + specification. */ + // FIXME: I don't think this can happen for a template + tree e_type = TREE_TYPE (existing); + tree e_spec = TYPE_RAISES_EXCEPTIONS (e_type); + if (DEFERRED_NOEXCEPT_SPEC_P (e_spec)) + { + tree d_type = TREE_TYPE (decl); + tree d_spec = TYPE_RAISES_EXCEPTIONS (d_type); + if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec) + || (UNEVALUATED_NOEXCEPT_SPEC_P (e_spec) + && !UNEVALUATED_NOEXCEPT_SPEC_P (d_spec))) + { + dump (dumper::MERGE) + && dump ("Propagating instantiated noexcept to %N", existing); + TREE_TYPE (existing) = d_type; + /* Propagate to existing clones. */ + tree clone; + FOR_EACH_CLONE (clone, existing) + { + if (TREE_TYPE (clone) == e_type) + TREE_TYPE (clone) = d_type; + else + TREE_TYPE (clone) + = build_exception_variant (TREE_TYPE (clone), d_spec); + } + } + } + } + if (DECL_IS_BUILTIN (existing) && DECL_ANTICIPATED (existing)) { // FIXME: Take the type from decl, see duplicate decls. FIXME: Our diff --git a/gcc/testsuite/g++.dg/modules/except-3.h b/gcc/testsuite/g++.dg/modules/except-3.h new file mode 100644 index 00000000000..8bf0f84d590 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/except-3.h @@ -0,0 +1,24 @@ + +template +struct is_nothrow_move_constructible +{ + static constexpr bool value = false; +}; + +template +struct _Tuple_impl +{ + _Tuple_impl () noexcept(is_nothrow_move_constructible<_Head>::value) + { } +}; + +template +void TPL (_Tuple_impl &) noexcept +{ + _Tuple_impl m; +} + +inline void foo (_Tuple_impl &p) +{ + TPL (p); +} diff --git a/gcc/testsuite/g++.dg/modules/except-3_a.H b/gcc/testsuite/g++.dg/modules/except-3_a.H new file mode 100644 index 00000000000..2f9f00e6222 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/except-3_a.H @@ -0,0 +1,6 @@ +// { dg-additional-options -fmodule-header } +// { dg-module-cmi {} } +// We end up with instantiated noexcept specs in the CMI data matching +// textually loaded fns with uninstantiated ones. Have to propagate, +// not reinstantiate. +#include "except-3.h" diff --git a/gcc/testsuite/g++.dg/modules/except-3_b.C b/gcc/testsuite/g++.dg/modules/except-3_b.C new file mode 100644 index 00000000000..0cb84725b5a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/except-3_b.C @@ -0,0 +1,7 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy -fdump-lang-module-alias" } + +#include "except-3.h" +import "except-3_a.H"; + +// { dg-final { scan-lang-dump-times {merge key \(new\) function_decl:'::_Tuple_impl::__[cd]t '} 3 module } } +// { dg-final { scan-lang-dump-times {Propagating instantiated noexcept to '::_Tuple_impl::__ct '} 1 module } }