xref: /aosp_15_r20/external/clang/test/CXX/drs/dr17xx.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 #if __cplusplus < 201103L
7*67e74705SXin Li // expected-no-diagnostics
8*67e74705SXin Li #endif
9*67e74705SXin Li 
10*67e74705SXin Li namespace dr1715 { // dr1715: 3.9
11*67e74705SXin Li #if __cplusplus >= 201103L
12*67e74705SXin Li   struct B {
13*67e74705SXin Li     template<class T> B(T, typename T::Q);
14*67e74705SXin Li   };
15*67e74705SXin Li 
16*67e74705SXin Li   class S {
17*67e74705SXin Li     using Q = int;
18*67e74705SXin Li     template<class T> friend B::B(T, typename T::Q);
19*67e74705SXin Li   };
20*67e74705SXin Li 
21*67e74705SXin Li   struct D : B {
22*67e74705SXin Li     using B::B;
23*67e74705SXin Li   };
24*67e74705SXin Li   struct E : B { // expected-note 2{{candidate}}
Edr1715::E25*67e74705SXin Li     template<class T> E(T t, typename T::Q q) : B(t, q) {} // expected-note {{'Q' is a private member}}
26*67e74705SXin Li   };
27*67e74705SXin Li 
28*67e74705SXin Li   B b(S(), 1);
29*67e74705SXin Li   D d(S(), 2);
30*67e74705SXin Li   E e(S(), 3); // expected-error {{no match}}
31*67e74705SXin Li #endif
32*67e74705SXin Li }
33*67e74705SXin Li 
34*67e74705SXin Li namespace dr1736 { // dr1736: 3.9
35*67e74705SXin Li #if __cplusplus >= 201103L
36*67e74705SXin Li struct S {
Sdr1736::S37*67e74705SXin Li   template <class T> S(T t) {
38*67e74705SXin Li     struct L : S {
39*67e74705SXin Li       using S::S;
40*67e74705SXin Li     };
41*67e74705SXin Li     typename T::type value; // expected-error {{no member}}
42*67e74705SXin Li     L l(value); // expected-note {{instantiation of}}
43*67e74705SXin Li   }
44*67e74705SXin Li };
45*67e74705SXin Li struct Q { typedef int type; } q;
46*67e74705SXin Li S s(q); // expected-note {{instantiation of}}
47*67e74705SXin Li #endif
48*67e74705SXin Li }
49*67e74705SXin Li 
50*67e74705SXin Li namespace dr1756 { // dr1756: 3.7
51*67e74705SXin Li #if __cplusplus >= 201103L
52*67e74705SXin Li   // Direct-list-initialization of a non-class object
53*67e74705SXin Li 
54*67e74705SXin Li   int a{0};
55*67e74705SXin Li 
56*67e74705SXin Li   struct X { operator int(); } x;
57*67e74705SXin Li   int b{x};
58*67e74705SXin Li #endif
59*67e74705SXin Li }
60*67e74705SXin Li 
61*67e74705SXin Li namespace dr1758 { // dr1758: 3.7
62*67e74705SXin Li #if __cplusplus >= 201103L
63*67e74705SXin Li   // Explicit conversion in copy/move list initialization
64*67e74705SXin Li 
65*67e74705SXin Li   struct X { X(); };
66*67e74705SXin Li   struct Y { explicit operator X(); } y;
67*67e74705SXin Li   X x{y};
68*67e74705SXin Li 
69*67e74705SXin Li   struct A {
Adr1758::A70*67e74705SXin Li     A() {}
Adr1758::A71*67e74705SXin Li     A(const A &) {}
72*67e74705SXin Li   };
73*67e74705SXin Li   struct B {
operator Adr1758::B74*67e74705SXin Li     operator A() { return A(); }
75*67e74705SXin Li   } b;
76*67e74705SXin Li   A a{b};
77*67e74705SXin Li #endif
78*67e74705SXin Li }
79