1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
7 // RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
10 #if __cplusplus >= 201103L
11 namespace cwg2211
{ // cwg2211: 8
14 auto f
= [a
](int a
) { (void)a
; };
15 // since-cxx11-error@-1 {{a lambda parameter cannot shadow an explicitly captured entity}}
16 // since-cxx11-note@-2 {{variable 'a' is explicitly captured here}}
17 auto g
= [=](int a
) { (void)a
; };
22 namespace cwg2213
{ // cwg2213: yes
23 template <typename T
, typename U
>
28 } // namespace cwg2213
30 namespace cwg2229
{ // cwg2229: 7
31 struct AnonBitfieldQualifiers
{
33 // expected-error@-1 {{anonymous bit-field cannot have qualifiers}}
34 volatile unsigned : 1;
35 // expected-error@-1 {{anonymous bit-field cannot have qualifiers}}
36 const volatile unsigned : 1;
37 // expected-error@-1 {{anonymous bit-field cannot have qualifiers}}
40 const unsigned i1
: 1;
41 volatile unsigned i2
: 1;
42 const volatile unsigned i3
: 1;
46 namespace cwg2233
{ // cwg2233: 11
47 #if __cplusplus >= 201103L
48 template <typename
... T
>
49 void f(int i
= 0, T
... args
) {}
51 template <typename
... T
>
52 void g(int i
= 0, T
... args
, T
... args2
) {}
54 template <typename
... T
>
55 void h(int i
= 0, T
... args
, int j
= 1) {}
57 template <typename
... T
, typename
... U
>
58 void i(int i
= 0, T
... args
, int j
= 1, U
... args2
) {}
60 template <class... Ts
>
61 void j(int i
= 0, Ts
... ts
) {}
64 void j
<int>(int i
, int j
) {}
67 void j(int, int, int);
70 void j(int, int, int, int);
73 // Ensure instantiating the templates works.
84 i
<int, int>(1, 2, 3, 4, 5);
91 namespace MultilevelSpecialization
{
92 template<typename
...T
> struct A
{
93 template <T
... V
> void f(int i
= 0, int (&... arr
)[V
]);
96 void A
<int, int>::f
<1, 1>(int i
, int (&arr1a
)[1], int (&arr2a
)[1]) {}
98 // FIXME: I believe this example is valid, at least up to the first explicit
99 // specialization, but Clang can't cope with explicit specializations that
100 // expand packs into a sequence of parameters. If we ever start accepting
101 // that, we'll need to decide whether it's OK for arr1a to be missing its
102 // default argument -- how far back do we look when determining whether a
103 // parameter was expanded from a pack?
104 // -- zygoloid 2020-06-02
105 template<typename
...T
> struct B
{ // #cwg2233-B
106 template <T
... V
> void f(int i
= 0, int (&... arr
)[V
]);
108 template<> template<int a
, int b
>
109 void B
<int, int>::f(int i
, int (&arr1
)[a
], int (&arr2
)[b
]) {}
110 // since-cxx11-error@-1 {{out-of-line definition of 'f' does not match any declaration in 'cwg2233::MultilevelSpecialization::B<int, int>'}}
111 // since-cxx11-note@#cwg2233-B {{defined here}}
112 template<> template<>
113 void B
<int, int>::f
<1, 1>(int i
, int (&arr1a
)[1], int (&arr2a
)[1]) {}
116 namespace CheckAfterMerging1
{
117 template <typename
... T
> void f() {
118 void g(int, int = 0);
119 void g(int = 0, T
...);
122 void h() { f
<int>(); }
125 namespace CheckAfterMerging2
{
126 template <typename
... T
> void f() {
127 void g(int = 0, T
...);
128 void g(int, int = 0);
131 void h() { f
<int>(); }
134 } // namespace cwg2233
136 namespace cwg2267
{ // cwg2267: no
137 #if __cplusplus >= 201103L
139 struct B
{ explicit B(const A
&); }; // #cwg2267-struct-B
142 struct C
{ explicit operator D(); } c
;
145 const B
&b2
{a
}; // FIXME ill-formed
147 // since-cxx11-error@-1 {{no viable conversion from 'struct A' to 'const B'}}
148 // since-cxx11-note@#cwg2267-struct-B {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'struct A' to 'const B &' for 1st argument}}
149 // since-cxx11-note@#cwg2267-struct-B {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'struct A' to 'B &&' for 1st argument}}
150 // since-cxx11-note@#cwg2267-struct-B {{explicit constructor is not a candidate}}
153 const D
&d2
{c
}; // FIXME ill-formed
154 const D
&d3(c
); // FIXME ill-formed
158 namespace cwg2273
{ // cwg2273: 3.3
159 #if __cplusplus >= 201103L
161 A(int = 0) = delete; // #cwg2273-A
164 struct B
: A
{ // #cwg2273-B
169 // since-cxx11-error@-1 {{call to implicitly-deleted default constructor of 'B'}}
170 // since-cxx11-note@#cwg2273-B {{default constructor of 'B' is implicitly deleted because base class 'A' has a deleted default constructor}}
171 // since-cxx11-note@#cwg2273-A {{'A' has been explicitly marked deleted here}}
175 namespace cwg2277
{ // cwg2277: partial
176 #if __cplusplus >= 201103L
179 void f(int, int = 0); // #cwg2277-A-f
185 void f(int); // #cwg2277-B-f
191 b
.f(0); // FIXME: this is well-formed for the same reason as initialization of 'b' above
192 // since-cxx11-error@-1 {{call to member function 'f' is ambiguous}}
193 // since-cxx11-note@#cwg2277-A-f {{candidate function}}
194 // since-cxx11-note@#cwg2277-B-f {{candidate function}}
199 namespace cwg2292
{ // cwg2292: 9
200 #if __cplusplus >= 201103L
201 template<typename T
> using id
= T
;
203 p
->template id
<int>::~id
<int>();