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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [initlist5.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
// Test for narrowing diagnostics
2
// { dg-options "-std=c++0x -pedantic-errors" }
3
 
4
#include 
5
 
6
struct A { int i; int j; };
7
A a2 { 1.2 }; // { dg-error "narrowing" }
8
A a1 { 1, 2 }; // aggregate initialization
9
struct B {
10
  B(std::initializer_list);
11
};
12
B b1 { 1, 2 }; // creates initializer_list and calls constructor
13
B b2 { 1, 2.0 }; // { dg-error "narrowing" }
14
struct C {
15
  C(int i, double j);
16
};
17
C c1 = { 1, 2.2 }; // calls constructor with arguments (1, 2.2)
18
C c2 = { 1.1, 2 }; // { dg-error "narrowing" }
19
 
20
int j { 1 }; // initialize to 1
21
int k {}; // initialize to 0
22
 
23
// PR c++/36963
24
double d = 1.1;
25
float fa[] = { d, 1.1 };      // { dg-error "narrowing conversion of 'd'" }
26
constexpr double d2 = 1.1;
27
float fa2[] = { d2, 1.1 };
28
 
29
// PR c++/49577
30
unsigned u{ -1 };               // { dg-error "narrowing" }
31
char c = char{ u };             // { dg-error "narrowing" }
32
 
33
// PR c++/50011
34
short unsigned su;
35
int i { su };

powered by: WebSVN 2.1.0

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