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
10 namespace dr1715 { // dr1715: 3.9
11 #if __cplusplus >= 201103L
12 struct B {
13 template<class T> B(T, typename T::Q);
14 };
15
16 class S {
17 using Q = int;
18 template<class T> friend B::B(T, typename T::Q);
19 };
20
21 struct D : B {
22 using B::B;
23 };
24 struct E : B { // expected-note 2{{candidate}}
Edr1715::E25 template<class T> E(T t, typename T::Q q) : B(t, q) {} // expected-note {{'Q' is a private member}}
26 };
27
28 B b(S(), 1);
29 D d(S(), 2);
30 E e(S(), 3); // expected-error {{no match}}
31 #endif
32 }
33
34 namespace dr1736 { // dr1736: 3.9
35 #if __cplusplus >= 201103L
36 struct S {
Sdr1736::S37 template <class T> S(T t) {
38 struct L : S {
39 using S::S;
40 };
41 typename T::type value; // expected-error {{no member}}
42 L l(value); // expected-note {{instantiation of}}
43 }
44 };
45 struct Q { typedef int type; } q;
46 S s(q); // expected-note {{instantiation of}}
47 #endif
48 }
49
50 namespace dr1756 { // dr1756: 3.7
51 #if __cplusplus >= 201103L
52 // Direct-list-initialization of a non-class object
53
54 int a{0};
55
56 struct X { operator int(); } x;
57 int b{x};
58 #endif
59 }
60
61 namespace dr1758 { // dr1758: 3.7
62 #if __cplusplus >= 201103L
63 // Explicit conversion in copy/move list initialization
64
65 struct X { X(); };
66 struct Y { explicit operator X(); } y;
67 X x{y};
68
69 struct A {
Adr1758::A70 A() {}
Adr1758::A71 A(const A &) {}
72 };
73 struct B {
operator Adr1758::B74 operator A() { return A(); }
75 } b;
76 A a{b};
77 #endif
78 }
79
80 namespace dr1722 { // dr1722: 9
81 #if __cplusplus >= 201103L
f()82 void f() {
83 const auto lambda = [](int x) { return x + 1; };
84 // Without the DR applied, this static_assert would fail.
85 static_assert(
86 noexcept((int (*)(int))(lambda)),
87 "Lambda-to-function-pointer conversion is expected to be noexcept");
88 }
89 #endif
90 } // namespace dr1722
91
92 namespace dr1778 { // dr1778: 9
93 // Superseded by P1286R2.
94 #if __cplusplus >= 201103L
95 struct A { A() noexcept(true) = default; };
96 struct B { B() noexcept(false) = default; };
97 static_assert(noexcept(A()), "");
98 static_assert(!noexcept(B()), "");
99
100 struct C { A a; C() noexcept(false) = default; };
101 struct D { B b; D() noexcept(true) = default; };
102 static_assert(!noexcept(C()), "");
103 static_assert(noexcept(D()), "");
104 #endif
105 }
106