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-7.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 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:1990 -pedantic-errors" } */
6
 
7
#include <float.h>
8
 
9
int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
10
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 9 } */
11
int b = (int) DBL_MAX; /* { dg-error "overflow" "" } */
12
unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */
13
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 12 } */
14
unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
15
 
16
int e = 0 << 1000; /* { dg-warning "shift count" } */
17
/* { dg-error "constant" "constant" { target *-*-* } 16 } */
18
int f = 0 << -1; /* { dg-warning "shift count" } */
19
/* { dg-error "constant" "constant" { target *-*-* } 18 } */
20
int g = 0 >> 1000; /* { dg-warning "shift count" } */
21
/* { dg-error "constant" "constant" { target *-*-* } 20 } */
22
int h = 0 >> -1; /* { dg-warning "shift count" } */
23
/* { dg-error "constant" "constant" { target *-*-* } 22 } */
24
 
25
int b1 = (0 ? (int) DBL_MAX : 0);
26
unsigned int d1 = (0 ? (unsigned int)-1.0 : 0);
27
int e1 = (0 ? 0 << 1000 : 0);
28
int f1 = (0 ? 0 << -1 : 0);
29
int g1 = (0 ? 0 >> 1000 : 0);
30
int h1 = (0 ? 0 >> -1: 0);
31
 
32
int i = -1 << 0;
33
 
34
int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
35
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 34 } */

powered by: WebSVN 2.1.0

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