OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / initlist5.C
1 // Test for narrowing diagnostics
2 // { dg-options "-std=c++0x" }
3
4 #include <initializer_list>
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<int>);
11 };
12 B b1 { 1, 2 }; // creates initializer_list<int> 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 const double d2 = 1.1;
27 float fa2[] = { d2, 1.1 };