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++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
7 // RUN: %clang_cc1 -std=c++2c %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
9 namespace dr1710
{ // dr1710: no
10 // FIXME: all of the following is well-formed
11 template <typename T
> struct D1
: T::template B
<int>::template C
<int> {};
12 template <typename T
> struct D2
: T::B
<int>::template C
<int> {};
13 // expected-error@-1 {{use 'template' keyword to treat 'B' as a dependent template name}}
14 template <typename T
> struct D3
: T::template B
<int>::C
<int> {};
15 // expected-error@-1 {{use 'template' keyword to treat 'C' as a dependent template name}}
16 template <typename T
> struct D4
: T::B
<int>::C
<int> {};
17 // expected-error@-1 {{use 'template' keyword to treat 'B' as a dependent template name}}
18 // expected-error@-2 {{use 'template' keyword to treat 'C' as a dependent template name}}
21 namespace dr1715
{ // dr1715: 3.9
22 #if __cplusplus >= 201103L
24 template<class T
> B(T
, typename
T::Q
);
29 template<class T
> friend B::B(T
, typename
T::Q
);
35 struct E
: B
{ // expected-note 2{{candidate}}
36 template<class T
> E(T t
, typename
T::Q q
) : B(t
, q
) {} // expected-note {{'Q' is a private member}}
41 E
e(S(), 3); // expected-error {{no match}}
45 namespace dr1722
{ // dr1722: 9
46 #if __cplusplus >= 201103L
48 const auto lambda
= [](int x
) { return x
+ 1; };
49 // Without the DR applied, this static_assert would fail.
51 noexcept((int (*)(int))(lambda
)),
52 "Lambda-to-function-pointer conversion is expected to be noexcept");
57 namespace dr1734
{ // dr1734: no
58 #if __cplusplus >= 201103L
62 // FIXME: 'A' should not be trivially copyable because the class lacks at least
63 // one non-deleted copy constructor, move constructor, copy assignment
64 // operator, or move assignment operator.
65 static_assert(__is_trivially_copyable(A
), "");
69 namespace dr1736
{ // dr1736: 3.9
70 #if __cplusplus >= 201103L
72 template <class T
> S(T t
) {
76 typename
T::type value
; // expected-error {{no member}}
77 L
l(value
); // expected-note {{instantiation of}}
80 struct Q
{ typedef int type
; } q
;
81 S
s(q
); // expected-note {{instantiation of}}
85 namespace dr1753
{ // dr1753: 11
87 struct A
{ typedef int T
; };
88 namespace B
{ typedef int T
; }
94 n
.dr1753::~T(); // expected-error {{'dr1753' does not refer to a type name in pseudo-destructor}}
97 n
.A::~T(); // expected-error {{the type of object expression ('T' (aka 'int')) does not match the type being destroyed ('A') in pseudo-destructor expression}}
100 n
.B::~T(); // expected-error {{'B' does not refer to a type name in pseudo-destructor expression}}
103 #if __cplusplus >= 201103L
104 n
.decltype(n
)::~T(); // expected-error {{not a class, namespace, or enumeration}}
105 n
.T::~decltype(n
)(); // expected-error {{expected a class name after '~'}}
106 n
.~decltype(n
)(); // OK
111 namespace dr1756
{ // dr1756: 3.7
112 #if __cplusplus >= 201103L
113 // Direct-list-initialization of a non-class object
117 struct X
{ operator int(); } x
;
122 namespace dr1758
{ // dr1758: 3.7
123 #if __cplusplus >= 201103L
124 // Explicit conversion in copy/move list initialization
127 struct Y
{ explicit operator X(); } y
;
135 operator A() { return A(); }
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 *);
150 namespace dr1778
{ // dr1778: 9
151 // Superseded by P1286R2.
152 #if __cplusplus >= 201103L
153 struct A
{ A() noexcept(true) = default; };
154 struct B
{ B() noexcept(false) = default; };
155 static_assert(noexcept(A()), "");
156 static_assert(!noexcept(B()), "");
158 struct C
{ A a
; C() noexcept(false) = default; };
159 struct D
{ B b
; D() noexcept(true) = default; };
160 static_assert(!noexcept(C()), "");
161 static_assert(noexcept(D()), "");
165 namespace dr1794
{ // dr1794: yes
167 #if __cplusplus >= 201103L
168 template <template <typename
> class Template
> struct Internal
{
169 template <typename Arg
> using Bind
= Template
<Arg
>;
172 template <template <typename
> class Template
, typename Arg
>
173 using Instantiate
= Template
<Arg
>;
175 template <template <typename
> class Template
, typename Argument
>
176 using Bind
= Instantiate
<Internal
<Template
>::template Bind
, Argument
>;
178 } // namespace dr1794