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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [warn/] [Wconversion3.C] - Blame information for rev 774

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

Line No. Rev Author Line
1 693 jeremybenn
// PR c++/34198
2
// { dg-do compile }
3
// { dg-options "-O2 -Wconversion -Wsign-conversion" }
4
 
5
signed char sc;
6
unsigned char uc;
7
short int ss;
8
unsigned short int us;
9
int si;
10
unsigned int ui;
11
 
12
void test1 (void)
13
{
14
  int a = uc & 0xff;
15
  int b = sc & 0x7f;
16
  int c = 0xff & uc;
17
  int d = 0x7f & sc;
18
  int e = uc & sc;
19
  unsigned char f = (int) uc;
20
  signed char g = (int) sc;
21
  unsigned char h = (unsigned int) (short int) uc;
22
  signed char i = (int) (unsigned short int) sc;        // { dg-warning "may alter its value" }
23
  unsigned char j = (unsigned int) (short int) us;      // { dg-warning "may alter its value" }
24
  signed char k = (int) (unsigned short int) ss;        // { dg-warning "may alter its value" }
25
}
26
 
27
void test2 (void)
28
{
29
  signed char a = (unsigned char) sc;           // { dg-warning "may change the sign" }
30
  unsigned char b = (signed char) uc;           // { dg-warning "may change the sign" }
31
  signed char c = (int) (unsigned char) sc;     // { dg-warning "may change the sign" }
32
  unsigned char d = (int) (signed char) uc;     // { dg-warning "may change the sign" }
33
  int e = (unsigned int) si;                    // { dg-warning "may change the sign" }
34
  unsigned int f = (int) ui;                    // { dg-warning "may change the sign" }
35
}

powered by: WebSVN 2.1.0

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