From patchwork Thu Jan 3 20:34:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for c++/55842 (ICE with noexcept and __has_nothrow_constructor) Date: Thu, 03 Jan 2013 10:34:42 -0000 From: Jason Merrill X-Patchwork-Id: 209308 Message-Id: <50E5EB62.8030009@redhat.com> To: gcc-patches List We need to instantiate a deferred noexcept when evaluationg __has_nothrow_constructor. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit 2b440f24a3319736c477523f65af741f97068ab6 Author: Jason Merrill Date: Thu Jan 3 14:38:54 2013 -0500 PR c++/55842 * semantics.c (trait_expr_value): Call maybe_instantiate_noexcept. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9f8119f..2e02295 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5454,7 +5454,8 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) return (trait_expr_value (CPTK_HAS_TRIVIAL_CONSTRUCTOR, type1, type2) || (CLASS_TYPE_P (type1) && (t = locate_ctor (type1)) - && TYPE_NOTHROW_P (TREE_TYPE (t)))); + && (maybe_instantiate_noexcept (t), + TYPE_NOTHROW_P (TREE_TYPE (t))))); case CPTK_HAS_TRIVIAL_CONSTRUCTOR: type1 = strip_array_types (type1); diff --git a/gcc/testsuite/g++.dg/ext/has_nothrow_constructor-2.C b/gcc/testsuite/g++.dg/ext/has_nothrow_constructor-2.C new file mode 100644 index 0000000..9191c3e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/has_nothrow_constructor-2.C @@ -0,0 +1,7 @@ +// PR c++/55842 +// { dg-options -std=c++11 } + +template struct number { + number() noexcept(noexcept(0)) { } +}; +const int z=__has_nothrow_constructor(number<>);