1 // RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
7 // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
9 namespace cwg1710
{ // cwg1710: 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}}
19 } // namespace cwg1710
21 namespace cwg1715
{ // cwg1715: 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
{ // #cwg1715-E
36 template<class T
> E(T t
, typename
T::Q q
) : B(t
, q
) {} // #cwg1715-E-ctor
42 // since-cxx11-error@-1 {{no matching constructor for initialization of 'E'}}
43 // since-cxx11-note@#cwg1715-E-ctor {{candidate template ignored: substitution failure [with T = S]: 'Q' is a private member of 'cwg1715::S'}}
44 // since-cxx11-note@#cwg1715-E {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided}}
45 // since-cxx11-note@#cwg1715-E {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided}}
49 namespace cwg1719
{ // cwg1719: 19
50 #if __cplusplus >= 201103L
61 struct CStructWithQualifiers
{
66 static_assert(__is_layout_compatible(CStruct
, const CStruct2
), "");
67 static_assert(__is_layout_compatible(CStruct
, volatile CStruct2
), "");
68 static_assert(__is_layout_compatible(const CStruct
, volatile CStruct2
), "");
69 static_assert(__is_layout_compatible(int, const int), "");
70 static_assert(__is_layout_compatible(int, volatile int), "");
71 static_assert(__is_layout_compatible(const int, volatile int), "");
72 static_assert(__is_layout_compatible(CStruct
, CStructWithQualifiers
), "");
73 static_assert(__is_layout_compatible(int[], const volatile int[]), "");
75 } // namespace cwg1719
77 namespace cwg1722
{ // cwg1722: 9
78 #if __cplusplus >= 201103L
80 const auto lambda
= [](int x
) { return x
+ 1; };
81 // Without the DR applied, this static_assert would fail.
83 noexcept((int (*)(int))(lambda
)),
84 "Lambda-to-function-pointer conversion is expected to be noexcept");
87 } // namespace cwg1722
89 namespace cwg1734
{ // cwg1734: no
90 #if __cplusplus >= 201103L
94 // FIXME: 'A' should not be trivially copyable because the class lacks at least
95 // one non-deleted copy constructor, move constructor, copy assignment
96 // operator, or move assignment operator.
97 static_assert(__is_trivially_copyable(A
), "");
101 namespace cwg1736
{ // cwg1736: 3.9
102 #if __cplusplus >= 201103L
104 template <class T
> S(T t
) {
108 typename
T::type value
;
109 // since-cxx11-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
110 // since-cxx11-note@#cwg1736-l {{in instantiation of function template specialization 'cwg1736::S::S<int>' requested here}}
111 // since-cxx11-note@#cwg1736-s {{in instantiation of function template specialization 'cwg1736::S::S<cwg1736::Q>' requested here}}
112 L
l(value
); // #cwg1736-l
115 struct Q
{ typedef int type
; } q
;
116 S
s(q
); // #cwg1736-s
120 namespace cwg1738
{ // cwg1738: sup P0136R1
121 #if __cplusplus >= 201103L
123 template <typename T
>
131 // FIXME: this is well-formed since P0136R1
132 template B::B(int, double);
133 // since-cxx11-error@-1 {{explicit instantiation of 'B' does not refer to a function template, variable template, member function, member class, or static data member}}
137 // cwg1748 is in cwg1748.cpp
139 namespace cwg1753
{ // cwg1753: 11
141 struct A
{ typedef int T
; };
142 namespace B
{ typedef int T
; }
149 // expected-error@-1 {{'cwg1753' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T' (aka 'int')}}
153 // expected-error@-1 {{the type of object expression ('T' (aka 'int')) does not match the type being destroyed ('A') in pseudo-destructor expression}}
157 // expected-error@-1 {{'B' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T' (aka 'int')}}
160 #if __cplusplus >= 201103L
162 // since-cxx11-error@-1 {{'decltype(n)' (aka 'int') is not a class, namespace, or enumeration}}
164 // since-cxx11-error@-1 {{expected a class name after '~' to name a destructor}}
165 n
.~decltype(n
)(); // OK
170 namespace cwg1756
{ // cwg1756: 3.7
171 #if __cplusplus >= 201103L
172 // Direct-list-initialization of a non-class object
176 struct X
{ operator int(); } x
;
181 namespace cwg1758
{ // cwg1758: 3.7
182 #if __cplusplus >= 201103L
183 // Explicit conversion in copy/move list initialization
186 struct Y
{ explicit operator X(); } y
;
194 operator A() { return A(); }
200 namespace cwg1762
{ // cwg1762: 14
201 #if __cplusplus >= 201103L
202 float operator ""_E(const char *);
203 float operator ""E(const char *);
204 // since-cxx11-error@-1 {{invalid suffix on literal; C++11 requires a space between literal and identifier}}
205 // since-cxx11-warning@-2 {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
209 // cwg1772 is in cwg177x.cpp
211 namespace cwg1778
{ // cwg1778: 9
212 // Superseded by P1286R2.
213 #if __cplusplus >= 201103L
214 struct A
{ A() noexcept(true) = default; };
215 struct B
{ B() noexcept(false) = default; };
216 static_assert(noexcept(A()), "");
217 static_assert(!noexcept(B()), "");
219 struct C
{ A a
; C() noexcept(false) = default; };
220 struct D
{ B b
; D() noexcept(true) = default; };
221 static_assert(!noexcept(C()), "");
222 static_assert(noexcept(D()), "");
226 // cwg1779 is in cwg177x.cpp
228 namespace cwg1794
{ // cwg1794: yes
230 #if __cplusplus >= 201103L
231 template <template <typename
> class Template
> struct Internal
{
232 template <typename Arg
> using Bind
= Template
<Arg
>;
235 template <template <typename
> class Template
, typename Arg
>
236 using Instantiate
= Template
<Arg
>;
238 template <template <typename
> class Template
, typename Argument
>
239 using Bind
= Instantiate
<Internal
<Template
>::template Bind
, Argument
>;
241 } // namespace cwg1794