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 dr1734 { // dr1734: no
31 #if __cplusplus >= 201103L
32 struct A {
33 A(const A&) = delete;
34 };
35 // FIXME: 'A' should not be trivially copyable because the class lacks at least
36 // one non-deleted copy constructor, move constructor, copy assignment
37 // operator, or move assignment operator.
38 static_assert(__is_trivially_copyable(A), "");
39 #endif
40 }
41
42 namespace dr1736 { // dr1736: 3.9
43 #if __cplusplus >= 201103L
44 struct S {
Sdr1736::S45 template <class T> S(T t) {
46 struct L : S {
47 using S::S;
48 };
49 typename T::type value; // expected-error {{no member}}
50 L l(value); // expected-note {{instantiation of}}
51 }
52 };
53 struct Q { typedef int type; } q;
54 S s(q); // expected-note {{instantiation of}}
55 #endif
56 }
57
58 namespace dr1753 { // dr1753: 11
59 typedef int T;
60 struct A { typedef int T; };
61 namespace B { typedef int T; }
62
f(T n)63 void f(T n) {
64 n.~T();
65 n.T::~T();
66
67 n.dr1753::~T(); // expected-error {{'dr1753' does not refer to a type name in pseudo-destructor}}
68 n.dr1753::T::~T();
69
70 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}}
71 n.A::T::~T();
72
73 n.B::~T(); // expected-error {{'B' does not refer to a type name in pseudo-destructor expression}}
74 n.B::T::~T();
75
76 #if __cplusplus >= 201103L
77 n.decltype(n)::~T(); // expected-error {{not a class, namespace, or enumeration}}
78 n.T::~decltype(n)(); // expected-error {{expected a class name after '~'}}
79 n.~decltype(n)(); // OK
80 #endif
81 }
82 }
83
84 namespace dr1756 { // dr1756: 3.7
85 #if __cplusplus >= 201103L
86 // Direct-list-initialization of a non-class object
87
88 int a{0};
89
90 struct X { operator int(); } x;
91 int b{x};
92 #endif
93 }
94
95 namespace dr1758 { // dr1758: 3.7
96 #if __cplusplus >= 201103L
97 // Explicit conversion in copy/move list initialization
98
99 struct X { X(); };
100 struct Y { explicit operator X(); } y;
101 X x{y};
102
103 struct A {
Adr1758::A104 A() {}
Adr1758::A105 A(const A &) {}
106 };
107 struct B {
operator Adr1758::B108 operator A() { return A(); }
109 } b;
110 A a{b};
111 #endif
112 }
113
114 namespace dr1722 { // dr1722: 9
115 #if __cplusplus >= 201103L
f()116 void f() {
117 const auto lambda = [](int x) { return x + 1; };
118 // Without the DR applied, this static_assert would fail.
119 static_assert(
120 noexcept((int (*)(int))(lambda)),
121 "Lambda-to-function-pointer conversion is expected to be noexcept");
122 }
123 #endif
124 } // namespace dr1722
125
126 namespace dr1778 { // dr1778: 9
127 // Superseded by P1286R2.
128 #if __cplusplus >= 201103L
129 struct A { A() noexcept(true) = default; };
130 struct B { B() noexcept(false) = default; };
131 static_assert(noexcept(A()), "");
132 static_assert(!noexcept(B()), "");
133
134 struct C { A a; C() noexcept(false) = default; };
135 struct D { B b; D() noexcept(true) = default; };
136 static_assert(!noexcept(C()), "");
137 static_assert(noexcept(D()), "");
138 #endif
139 }
140
141 namespace dr1762 { // dr1762: 14
142 #if __cplusplus >= 201103L
143 float operator ""_E(const char *);
144 // expected-error@+2 {{invalid suffix on literal; C++11 requires a space between literal and identifier}}
145 // expected-warning@+1 {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
146 float operator ""E(const char *);
147 #endif
148 }
149