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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [warn/] [Wconversion-real-integer.C] - Blame information for rev 801

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

Line No. Rev Author Line
1 693 jeremybenn
/* Test for diagnostics for Wconversion between floating-point and
2
   integers. C++ equivalent of
3
   gcc/testsuite/gcc.dg/Wconversion-real-integer.c */
4
 
5
/* { dg-do compile }
6
/* { dg-options "-Wconversion" } */
7
/* { dg-require-effective-target int32plus } */
8
#include 
9
 
10
void fsi (signed int x);
11
void fui (unsigned int x);
12
void ffloat (float x);
13
void fdouble (double x);
14
 
15
float  vfloat;
16
double vdouble;
17
 
18
void h (void)
19
{
20
  unsigned int ui = 3;
21
  int   si = 3;
22
  unsigned char uc = 3;
23
  signed char sc = 3;
24
  float  f = 3;
25
  double d = 3;
26
 
27
  fsi (3.1f); /* { dg-warning "conversion" } */
28
  si = 3.1f; /* { dg-warning "conversion" } */
29
  fsi (3.1);  /* { dg-warning "conversion" } */
30
  si = 3.1;  /* { dg-warning "conversion" } */
31
  fsi (d);    /* { dg-warning "conversion" } */
32
  si = d;    /* { dg-warning "conversion" } */
33
  fui (-1.0); /* { dg-warning "overflow" } */
34
  ui = -1.0;   /* { dg-warning "overflow" } */
35
  ffloat (INT_MAX);  /* { dg-warning "conversion" } */
36
  vfloat = INT_MAX;  /* { dg-warning "conversion" } */
37
  ffloat (16777217); /* { dg-warning "conversion" } */
38
  vfloat = 16777217; /* { dg-warning "conversion" } */
39
  ffloat (si); /* { dg-warning "conversion" } */
40
  vfloat = si; /* { dg-warning "conversion" } */
41
  ffloat (ui); /* { dg-warning "conversion" } */
42
  vfloat = ui; /* { dg-warning "conversion" } */
43
 
44
  fsi (3);
45
  si = 3;
46
  fsi (3.0f);
47
  si = 3.0f;
48
  fsi (3.0);
49
  si = 3.0;
50
  fsi (16777217.0f);
51
  si = 16777217.0f;
52
  fsi ((int) 3.1);
53
  si = (int) 3.1;
54
  ffloat (3U);
55
  vfloat = 3U;
56
  ffloat (3);
57
  vfloat = 3;
58
  ffloat (INT_MIN);
59
  vfloat = INT_MIN;
60
  ffloat (uc);
61
  vfloat = uc;
62
  ffloat (sc);
63
  vfloat = sc;
64
 
65
  fdouble (UINT_MAX);
66
  vdouble = UINT_MAX;
67
  fdouble (ui);
68
  vdouble = ui;
69
  fdouble (si);
70
  vdouble = si;
71
}
72
 
73
 
74
void fss (signed short x);
75
void fus (unsigned short x);
76
void fsc (signed char x);
77
void fuc (unsigned char x);
78
 
79
void h2 (void)
80
{
81
  unsigned short int us;
82
  short int   ss;
83
  unsigned char uc;
84
  signed char sc;
85
 
86
  fss (4294967294.0); /* { dg-warning "conversion" } */
87
  ss = 4294967294.0; /* { dg-warning "conversion" } */
88
  fss (-4294967294.0);  /* { dg-warning "conversion" } */
89
  ss = -4294967294.0;  /* { dg-warning "conversion" } */
90
  fus (4294967294.0); /* { dg-warning "conversion" } */
91
  us = 4294967294.0; /* { dg-warning "conversion" } */
92
  fus (-4294967294.0);  /* { dg-warning "conversion" } */
93
  us = -4294967294.0;  /* { dg-warning "conversion" } */
94
 
95
  fsc (500.0); /* { dg-warning "conversion" } */
96
  sc = 500.0; /* { dg-warning "conversion" } */
97
  fsc (-500.0);  /* { dg-warning "conversion" } */
98
  sc = -500.0;  /* { dg-warning "conversion" } */
99
  fuc (500.0); /* { dg-warning "conversion" } */
100
  uc = 500.0; /* { dg-warning "conversion" } */
101
  fuc (-500.0);  /* { dg-warning "conversion" } */
102
  uc = -500.0;  /* { dg-warning "conversion" } */
103
 
104
  fss (500.0);
105
  ss = 500.0;
106
  fss (-500.0);
107
  ss = -500.0;
108
  fus (500.0);
109
  us = 500.0;
110
  fus (-500.0);   /* { dg-warning "conversion" } */
111
  us = -500.0;    /* { dg-warning "conversion" } */
112
}

powered by: WebSVN 2.1.0

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