1  /* Test for constant expressions: VLA size constraints.  */
       2  /* Origin: Joseph Myers <joseph@codesourcery.com> */
       3  /* { dg-do compile } */
       4  /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
       5  
       6  void
       7  f (int m)
       8  {
       9    /* An array size that is a constant expression, not just an integer
      10       constant expression, must be checked for being positive, but only
      11       an integer constant expression makes it not a VLA (which affects
      12       certain compatibility checks, in particular).  */
      13    int a1[0]; /* { dg-error "zero" } */
      14    int a2[-1]; /* { dg-error "negative" } */
      15    int a3[(int)(double)0.0]; /* { dg-error "zero" } */
      16    int a4[(int)-1.0]; /* { dg-error "negative" } */
      17    int a5[(int)+1.0];
      18    int a6[(int)+2.0];
      19    void *p = (m ? &a5 : &a6);
      20    int a7[(int)1.0];
      21    int a8[(int)2.0];
      22    void *q = (m ? &a7 : &a8); /* { dg-error "pointer type mismatch in conditional expression" } */
      23  }