1// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5
6#if __cplusplus < 201103L
7// expected-no-diagnostics
8#endif
9
10namespace std {
11  __extension__ typedef __SIZE_TYPE__ size_t;
12
13  template<typename T> struct initializer_list {
14    const T *p; size_t n;
15    initializer_list(const T *p, size_t n);
16  };
17}
18
19namespace dr990 { // dr990: 3.5
20#if __cplusplus >= 201103L
21  struct A { // expected-note 2{{candidate}}
22    A(std::initializer_list<int>); // expected-note {{candidate}}
23  };
24  struct B {
25    A a;
26  };
27  B b1 { };
28  B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'dr990::A'}}
29  B b3 { { 1 } };
30
31  struct C {
32    C();
33    C(int);
34    C(std::initializer_list<int>) = delete; // expected-note {{here}}
35  };
36  C c1[3] { 1 }; // ok
37  C c2[3] { 1, {2} }; // expected-error {{call to deleted}}
38
39  struct D {
40    D();
41    D(std::initializer_list<int>);
42    D(std::initializer_list<double>);
43  };
44  D d{};
45#endif
46}
47
48namespace dr948 { // dr948: 3.7
49#if __cplusplus >= 201103L
50  class A {
51  public:
52     constexpr A(int v) : v(v) { }
53     constexpr operator int() const { return v; }
54  private:
55     int v;
56  };
57
58  constexpr int id(int x)
59  {
60    return x;
61  }
62
63  void f() {
64     if (constexpr int i = id(101)) { }
65     switch (constexpr int i = id(2)) { default: break; case 2: break; }
66     for (; constexpr int i = id(0); ) { }
67     while (constexpr int i = id(0)) { }
68
69     if (constexpr A i = 101) { }
70     switch (constexpr A i = 2) { default: break; case 2: break; }
71     for (; constexpr A i = 0; ) { }
72     while (constexpr A i = 0) { }
73  }
74#endif
75}
76