This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [PR c++/84968] reject stmt-exprs in noexcept constexprs


OK.

On Fri, Mar 23, 2018 at 11:27 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> We reject extended statement-expressions in template parameters, so we
> might as well reject them in constant expressions used in noexcept
> specifications.
>
> Regstrapped on i686- and x86_64-linux-gnu.  Ok to install?
>
> for  gcc/cp/ChangeLog
>
>         PR c++/84968
>         * tree.c (strip_typedefs_expr): Reject STATEMENT_LISTs.
>
> for  gcc/testsuite/ChangeLog
>
>         PR c++/84968
>         * g++.dg/eh/pr84968.C: New.
> ---
>  gcc/cp/tree.c                     |    4 ++++
>  gcc/testsuite/g++.dg/eh/pr84968.C |   15 +++++++++++++++
>  2 files changed, 19 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/eh/pr84968.C
>
> diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
> index f1a90bdec0fc..070bd11a0591 100644
> --- a/gcc/cp/tree.c
> +++ b/gcc/cp/tree.c
> @@ -1785,6 +1785,10 @@ strip_typedefs_expr (tree t, bool *remove_attributes)
>        error ("lambda-expression in a constant expression");
>        return error_mark_node;
>
> +    case STATEMENT_LIST:
> +      error ("statement-expression in a constant expression");
> +      return error_mark_node;
> +
>      default:
>        break;
>      }
> diff --git a/gcc/testsuite/g++.dg/eh/pr84968.C b/gcc/testsuite/g++.dg/eh/pr84968.C
> new file mode 100644
> index 000000000000..23c49f477a88
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/eh/pr84968.C
> @@ -0,0 +1,15 @@
> +// { dg-do compile { target c++11 } }
> +
> +// { dg-options "" }
> +
> +union b;
> +
> +struct S {
> +  template <typename>
> +  void a()
> +    try {
> +    } catch (int ()
> +            noexcept (({ union b a; true; }))) // { dg-error "constant" }
> +  {
> +  }
> +};
>
>
> --
> Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/   FSF Latin America board member
> Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]