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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [c99-const-expr-7.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Test for constant expressions: overflow and constant expressions;
2
   see also overflow-warn-*.c for some other cases.  */
3
/* Origin: Joseph Myers <joseph@codesourcery.com> */
4
/* { dg-do compile } */
5
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
6
 
7
#include <float.h>
8
#include <limits.h>
9
 
10
int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
11
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 10 } */
12
int b = (int) DBL_MAX; /* { dg-error "overflow" "" } */
13
unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */
14
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 13 } */
15
unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
16
 
17
int e = 0 << 1000; /* { dg-warning "shift count" } */
18
/* { dg-error "constant" "constant" { target *-*-* } 17 } */
19
int f = 0 << -1; /* { dg-warning "shift count" } */
20
/* { dg-error "constant" "constant" { target *-*-* } 19 } */
21
int g = 0 >> 1000; /* { dg-warning "shift count" } */
22
/* { dg-error "constant" "constant" { target *-*-* } 21 } */
23
int h = 0 >> -1; /* { dg-warning "shift count" } */
24
/* { dg-error "constant" "constant" { target *-*-* } 23 } */
25
 
26
int b1 = (0 ? (int) DBL_MAX : 0);
27
unsigned int d1 = (0 ? (unsigned int)-1.0 : 0);
28
int e1 = (0 ? 0 << 1000 : 0);
29
int f1 = (0 ? 0 << -1 : 0);
30
int g1 = (0 ? 0 >> 1000 : 0);
31
int h1 = (0 ? 0 >> -1: 0);
32
 
33
/* Allowed for now, but actually undefined behavior in C99.  */
34
int i = -1 << 0;
35
 
36
int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
37
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 36 } */
38
 
39
int array[2] = { [0 * (INT_MAX + 1)] = 0 }; /* { dg-warning "integer overflow in expression" } */
40
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 39 } */
41
 
42
_Bool k = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
43
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 42 } */

powered by: WebSVN 2.1.0

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