xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/drs/dr9xx.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L
7*0a6a1f1dSLionel Sambuc // expected-no-diagnostics
8*0a6a1f1dSLionel Sambuc #endif
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc namespace std {
11*0a6a1f1dSLionel Sambuc   __extension__ typedef __SIZE_TYPE__ size_t;
12*0a6a1f1dSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc   template<typename T> struct initializer_list {
14*0a6a1f1dSLionel Sambuc     const T *p; size_t n;
15*0a6a1f1dSLionel Sambuc     initializer_list(const T *p, size_t n);
16*0a6a1f1dSLionel Sambuc   };
17*0a6a1f1dSLionel Sambuc }
18*0a6a1f1dSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc namespace dr990 { // dr990: 3.5
20*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L
21*0a6a1f1dSLionel Sambuc   struct A { // expected-note 2{{candidate}}
22*0a6a1f1dSLionel Sambuc     A(std::initializer_list<int>); // expected-note {{candidate}}
23*0a6a1f1dSLionel Sambuc   };
24*0a6a1f1dSLionel Sambuc   struct B {
25*0a6a1f1dSLionel Sambuc     A a;
26*0a6a1f1dSLionel Sambuc   };
27*0a6a1f1dSLionel Sambuc   B b1 { };
28*0a6a1f1dSLionel Sambuc   B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'dr990::A'}}
29*0a6a1f1dSLionel Sambuc   B b3 { { 1 } };
30*0a6a1f1dSLionel Sambuc 
31*0a6a1f1dSLionel Sambuc   struct C {
32*0a6a1f1dSLionel Sambuc     C();
33*0a6a1f1dSLionel Sambuc     C(int);
34*0a6a1f1dSLionel Sambuc     C(std::initializer_list<int>) = delete; // expected-note {{here}}
35*0a6a1f1dSLionel Sambuc   };
36*0a6a1f1dSLionel Sambuc   C c1[3] { 1 }; // ok
37*0a6a1f1dSLionel Sambuc   C c2[3] { 1, {2} }; // expected-error {{call to deleted}}
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc   struct D {
40*0a6a1f1dSLionel Sambuc     D();
41*0a6a1f1dSLionel Sambuc     D(std::initializer_list<int>);
42*0a6a1f1dSLionel Sambuc     D(std::initializer_list<double>);
43*0a6a1f1dSLionel Sambuc   };
44*0a6a1f1dSLionel Sambuc   D d{};
45*0a6a1f1dSLionel Sambuc #endif
46*0a6a1f1dSLionel Sambuc }
47