OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [c90-const-expr-6.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test for constant expressions: operands and casts not permitted in
2
   integer constant expressions.  */
3
/* Origin: Joseph Myers <joseph@codesourcery.com> */
4
/* { dg-do compile } */
5
/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
6
 
7
__extension__ typedef __PTRDIFF_TYPE__ ptrdiff_t;
8
 
9
/* PR 29116.  */
10
int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|can't be evaluated" } */
11
 
12
/* PR 31871.  */
13
extern int c[1 + ((ptrdiff_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
14
 
15
/* Implicit conversions from floating-point constants are not OK,
16
   although explicit ones are.  */
17
extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab|can't be evaluated" } */
18
 
19
extern int c2[(int)1.0 ? 1 : 0];
20
 
21
extern int c3[1.0 && 1]; /* { dg-error "variab|can't be evaluated" } */
22
 
23
extern int c4[(int)1.0 && 1];
24
 
25
extern int c5[1.0 || 1]; /* { dg-error "variab|can't be evaluated" } */
26
 
27
extern int c6[(int)1.0 || 1];
28
 
29
/* Similar with various other cases where integer constant expressions
30
   are required.  */
31
 
32
struct s {
33
  int a : (n * 0 + 1); /* { dg-error "constant" } */
34
};
35
 
36
enum e {
37
  E = (1 + ((ptrdiff_t) (void *) 0)), /* { dg-error "constant" } */
38
  E2 = 0
39
};
40
 
41
enum f {
42
  F = (1 ? 1 : n), /* { dg-error "constant" } */
43
  F2 = 0
44
};
45
 
46
void
47
f (int a)
48
{
49
  int v[1 + ((ptrdiff_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
50
  switch (a)
51
    {
52
    case (n * 0 + 1): /* { dg-error "constant" } */
53
      ;
54
    }
55
}

powered by: WebSVN 2.1.0

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