xref: /aosp_15_r20/external/clang/test/CXX/drs/dr10xx.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3*67e74705SXin Li // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5*67e74705SXin Li 
6*67e74705SXin Li // expected-no-diagnostics
7*67e74705SXin Li 
8*67e74705SXin Li namespace std {
9*67e74705SXin Li   __extension__ typedef __SIZE_TYPE__ size_t;
10*67e74705SXin Li 
11*67e74705SXin Li   template<typename T> struct initializer_list {
12*67e74705SXin Li     const T *p; size_t n;
13*67e74705SXin Li     initializer_list(const T *p, size_t n);
14*67e74705SXin Li   };
15*67e74705SXin Li }
16*67e74705SXin Li 
17*67e74705SXin Li namespace dr1048 { // dr1048: 3.6
18*67e74705SXin Li   struct A {};
19*67e74705SXin Li   const A f();
20*67e74705SXin Li   A g();
21*67e74705SXin Li   typedef const A CA;
22*67e74705SXin Li #if __cplusplus >= 201103L
23*67e74705SXin Li   // ok: we deduce non-const A in each case.
__anon0b85bbdc0102(int n) 24*67e74705SXin Li   A &&a = [] (int n) {
25*67e74705SXin Li     while (1) switch (n) {
26*67e74705SXin Li       case 0: return f();
27*67e74705SXin Li       case 1: return g();
28*67e74705SXin Li       case 2: return A();
29*67e74705SXin Li       case 3: return CA();
30*67e74705SXin Li     }
31*67e74705SXin Li   } (0);
32*67e74705SXin Li #endif
33*67e74705SXin Li }
34*67e74705SXin Li 
35*67e74705SXin Li namespace dr1070 { // dr1070: 3.5
36*67e74705SXin Li #if __cplusplus >= 201103L
37*67e74705SXin Li   struct A {
38*67e74705SXin Li     A(std::initializer_list<int>);
39*67e74705SXin Li   };
40*67e74705SXin Li   struct B {
41*67e74705SXin Li     int i;
42*67e74705SXin Li     A a;
43*67e74705SXin Li   };
44*67e74705SXin Li   B b = {1};
45*67e74705SXin Li   struct C {
46*67e74705SXin Li     std::initializer_list<int> a;
47*67e74705SXin Li     B b;
48*67e74705SXin Li     std::initializer_list<double> c;
49*67e74705SXin Li   };
50*67e74705SXin Li   C c = {};
51*67e74705SXin Li #endif
52*67e74705SXin Li }
53