diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9ccb801dc7b..98a1b799842 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-12-21 Paolo Carlini + + PR c++/51305 + * semantics.c (massage_constexpr_body): Reorder conditionals, make + sure a BIND_EXPR embedded in a MUST_NOT_THROW_EXPR is handled. + 2011-12-20 Paolo Carlini PR c++/51621 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0cb7ae860d5..bad418f97ca 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5998,12 +5998,12 @@ massage_constexpr_body (tree fun, tree body) (DECL_CONTEXT (fun), body); else { - if (TREE_CODE (body) == BIND_EXPR) - body = BIND_EXPR_BODY (body); if (TREE_CODE (body) == EH_SPEC_BLOCK) body = EH_SPEC_STMTS (body); if (TREE_CODE (body) == MUST_NOT_THROW_EXPR) body = TREE_OPERAND (body, 0); + if (TREE_CODE (body) == BIND_EXPR) + body = BIND_EXPR_BODY (body); body = constexpr_fn_retval (body); } return body; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b0e247c0413..8e43e3d3efe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-21 Paolo Carlini + + PR c++/51305 + * g++.dg/cpp0x/constexpr-noexcept6.C: New. + 2011-12-21 Jakub Jelinek PR middle-end/51644 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept6.C new file mode 100644 index 00000000000..91e93fd91bc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept6.C @@ -0,0 +1,10 @@ +// PR c++/51305 +// { dg-options -std=c++0x } + +constexpr bool ok() noexcept +{ + typedef int type; + return true; +} + +constexpr auto x = ok();