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 namespace dr1715 { // dr1715: 3.9
7 #if __cplusplus >= 201103L
8   struct B {
9     template<class T> B(T, typename T::Q);
10   };
11 
12   class S {
13     using Q = int;
14     template<class T> friend B::B(T, typename T::Q);
15   };
16 
17   struct D : B {
18     using B::B;
19   };
20   struct E : B { // expected-note 2{{candidate}}
Edr1715::E21     template<class T> E(T t, typename T::Q q) : B(t, q) {} // expected-note {{'Q' is a private member}}
22   };
23 
24   B b(S(), 1);
25   D d(S(), 2);
26   E e(S(), 3); // expected-error {{no match}}
27 #endif
28 }
29 
30 namespace dr1736 { // dr1736: 3.9
31 #if __cplusplus >= 201103L
32 struct S {
Sdr1736::S33   template <class T> S(T t) {
34     struct L : S {
35       using S::S;
36     };
37     typename T::type value; // expected-error {{no member}}
38     L l(value); // expected-note {{instantiation of}}
39   }
40 };
41 struct Q { typedef int type; } q;
42 S s(q); // expected-note {{instantiation of}}
43 #endif
44 }
45 
46 namespace dr1753 { // dr1753: 11
47   typedef int T;
48   struct A { typedef int T; };
49   namespace B { typedef int T; }
50 
f(T n)51   void f(T n) {
52     n.~T();
53     n.T::~T();
54 
55     n.dr1753::~T(); // expected-error {{'dr1753' does not refer to a type name in pseudo-destructor}}
56     n.dr1753::T::~T();
57 
58     n.A::~T(); // expected-error {{the type of object expression ('dr1753::T' (aka 'int')) does not match the type being destroyed ('dr1753::A') in pseudo-destructor expression}}
59     n.A::T::~T();
60 
61     n.B::~T(); // expected-error {{'B' does not refer to a type name in pseudo-destructor expression}}
62     n.B::T::~T();
63 
64   #if __cplusplus >= 201103L
65     n.decltype(n)::~T(); // expected-error {{not a class, namespace, or enumeration}}
66     n.T::~decltype(n)(); // expected-error {{expected a class name after '~'}}
67     n.~decltype(n)(); // OK
68   #endif
69   }
70 }
71 
72 namespace dr1756 { // dr1756: 3.7
73 #if __cplusplus >= 201103L
74   // Direct-list-initialization of a non-class object
75 
76   int a{0};
77 
78   struct X { operator int(); } x;
79   int b{x};
80 #endif
81 }
82 
83 namespace dr1758 { // dr1758: 3.7
84 #if __cplusplus >= 201103L
85   // Explicit conversion in copy/move list initialization
86 
87   struct X { X(); };
88   struct Y { explicit operator X(); } y;
89   X x{y};
90 
91   struct A {
Adr1758::A92     A() {}
Adr1758::A93     A(const A &) {}
94   };
95   struct B {
operator Adr1758::B96     operator A() { return A(); }
97   } b;
98   A a{b};
99 #endif
100 }
101 
102 namespace dr1722 { // dr1722: 9
103 #if __cplusplus >= 201103L
f()104 void f() {
105   const auto lambda = [](int x) { return x + 1; };
106   // Without the DR applied, this static_assert would fail.
107   static_assert(
108       noexcept((int (*)(int))(lambda)),
109       "Lambda-to-function-pointer conversion is expected to be noexcept");
110 }
111 #endif
112 } // namespace dr1722
113 
114 namespace dr1778 { // dr1778: 9
115   // Superseded by P1286R2.
116 #if __cplusplus >= 201103L
117   struct A { A() noexcept(true) = default; };
118   struct B { B() noexcept(false) = default; };
119   static_assert(noexcept(A()), "");
120   static_assert(!noexcept(B()), "");
121 
122   struct C { A a; C() noexcept(false) = default; };
123   struct D { B b; D() noexcept(true) = default; };
124   static_assert(!noexcept(C()), "");
125   static_assert(noexcept(D()), "");
126 #endif
127 }
128