OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [c99-const-expr-12.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.