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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [warn/] [Wconversion-integer.C] - Blame information for rev 307

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

Line No. Rev Author Line
1 301 jeremybenn
/* Test for diagnostics for implicit conversions between integer types
2
   C++ equivalent of gcc/testsuite/gcc.dg/Wconversion-integer.c  */
3
 
4
// { dg-do compile }
5
// { dg-options "-fsigned-char -Wconversion" }
6
 
7
#include 
8
 
9
void fsc (signed char sc);
10
void fuc (unsigned char uc);
11
unsigned fui (unsigned int  ui);
12
void fsi (signed int ui);
13
 
14
void h (int x)
15
{
16
  unsigned int ui = 3;
17
  int   si = 3;
18
  unsigned char uc = 3;
19
  signed char   sc = 3;
20
 
21
  uc = ui; /* { dg-warning "conversion" } */
22
  uc = si; /* { dg-warning "conversion" } */
23
  sc = ui; /* { dg-warning "conversion" } */
24
  sc = si; /* { dg-warning "conversion" } */
25
  fuc (ui); /* { dg-warning "conversion" } */
26
  fuc (si); /* { dg-warning "conversion" } */
27
  fsc (ui); /* { dg-warning "conversion" } */
28
  fsc (si); /* { dg-warning "conversion" } */
29
 
30
  fsi (si);
31
  fui (ui);
32
  fsi (uc);
33
  si = uc;
34
  fui (uc);
35
  ui = uc;
36
  fui ('A');
37
  ui = 'A';
38
  fsi ('A');
39
  si = 'A';
40
  fuc ('A');
41
  uc = 'A';
42
 
43
  uc = x ? 1U : -1; /* { dg-warning "conversion" } */
44
  uc = x ? SCHAR_MIN : 1U; /* { dg-warning "conversion" } */
45
  uc = x ? 1 : -1; /* Warned by -Wsign-conversion.  */
46
  uc = x ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion.  */
47
  ui = x ? 1U : -1; /* Warned by -Wsign-conversion.  */
48
  ui = x ? INT_MIN : 1U; /* Warned by -Wsign-conversion.  */
49
  ui = ui ? SCHAR_MIN : 1U; /* Warned by -Wsign-conversion.  */
50
  ui = 1U * -1; /* Warned by -Wsign-conversion.  */
51
  ui = ui + INT_MIN; /* Warned by -Wsign-conversion.  */
52
  ui = x ? 1 : -1; /* Warned by -Wsign-conversion.  */
53
  ui = ui ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion.  */
54
 
55
  fuc (-1); /* Warned by -Wsign-conversion.  */
56
  uc = -1; /* Warned by -Wsign-conversion.  */
57
  fui (-1); /* Warned by -Wsign-conversion.  */
58
  ui = -1; /* Warned by -Wsign-conversion.  */
59
  fuc ('\xa0'); /* Warned by -Wsign-conversion.  */
60
  uc = '\xa0'; /* Warned by -Wsign-conversion.  */
61
  fui ('\xa0'); /* Warned by -Wsign-conversion.  */
62
  ui = '\xa0';  /* Warned by -Wsign-conversion.  */
63
  fsi (0x80000000); /* Warned by -Wsign-conversion.  */
64
  si = 0x80000000;  /* Warned by -Wsign-conversion.  */
65
 
66
 
67
  fsi (UINT_MAX - 1);  /* Warned by -Wsign-conversion.  */
68
  si = UINT_MAX - 1;   /* Warned by -Wsign-conversion.  */
69
  fsi (UINT_MAX - 1U); /* Warned by -Wsign-conversion.  */
70
  si = UINT_MAX - 1U;  /* Warned by -Wsign-conversion.  */
71
  fsi (UINT_MAX/3U);
72
  si = UINT_MAX/3U;
73
  fsi (UINT_MAX/3);
74
  si = UINT_MAX/3;
75
  fui (UINT_MAX - 1);
76
  ui = UINT_MAX - 1;
77
 
78
  uc = (unsigned char) -1;
79
  ui = -1 * (1 * -1);
80
  ui = (unsigned) -1;
81
 
82
  fsc (uc); /* Warned by -Wsign-conversion.  */
83
  sc = uc;  /* Warned by -Wsign-conversion.  */
84
  fuc (sc); /* Warned by -Wsign-conversion.  */
85
  uc = sc;  /* Warned by -Wsign-conversion.  */
86
  fsi (ui); /* Warned by -Wsign-conversion.  */
87
  si = ui;  /* Warned by -Wsign-conversion.  */
88
  fui (si); /* Warned by -Wsign-conversion.  */
89
  ui = si;  /* Warned by -Wsign-conversion.  */
90
  fui (sc); /* Warned by -Wsign-conversion.  */
91
  ui = sc;  /* Warned by -Wsign-conversion.  */
92
}
93
 
94
unsigned fui (unsigned a) { return a + -1; } /* Warned by -Wsign-conversion.  */

powered by: WebSVN 2.1.0

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