OK.

On Wed, Oct 5, 2016 at 5:47 PM, Marek Polacek <pola...@redhat.com> wrote:
> This adds a further test for selection statements with initializer C++17
> feature.  Except that I'm not quite sure if it's valid, but I think it is;
> although the standard says
> An if statement of the form
>
>   if constexpr opt ( init-statement condition ) statement
>
> is equivalent to
>
>   {
>     init-statement
>     if constexpr opt ( condition ) statement
>   }
>
> it also says "except that names declared in the init-statement are in the same
> declarative region as those declared in the condition."
> and program like
>
>   if (int x = 4)
>     {
>       int x;
>     }
> is ill-formed.
>
> Ok for trunk?
>
> 2016-10-05  Marek Polacek  <pola...@redhat.com>
>
>         * g++.dg/cpp1z/init-statement9.C: New test.
>
> diff --git gcc/testsuite/g++.dg/cpp1z/init-statement9.C 
> gcc/testsuite/g++.dg/cpp1z/init-statement9.C
> index e69de29..5425f97 100644
> --- gcc/testsuite/g++.dg/cpp1z/init-statement9.C
> +++ gcc/testsuite/g++.dg/cpp1z/init-statement9.C
> @@ -0,0 +1,17 @@
> +// { dg-options -std=c++1z }
> +
> +void
> +f ()
> +{
> +  {
> +    int c;
> +    if (int c = 2; c != 0)
> +      int c = 4; // { dg-error "redeclaration" }
> +  }
> +
> +  if (int c = 2; c != 0)
> +    int c = 4; // { dg-error "redeclaration" }
> +
> +  if (int c = 2; int c = 6) // { dg-error "redeclaration" }
> +    int c = 4; // { dg-error "redeclaration" }
> +}
>
>         Marek

Reply via email to