1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 #if __cplusplus >= 201103L
7 namespace dr2211
{ // dr2211: 8
10 auto f
= [a
](int a
) { (void)a
; }; // expected-error {{a lambda parameter cannot shadow an explicitly captured entity}}
11 // expected-note@-1{{variable 'a' is explicitly captured here}}
12 auto g
= [=](int a
) { (void)a
; };
17 namespace dr2213
{ // dr2213: yes
18 template <typename T
, typename U
>
25 namespace dr2229
{ // dr2229: 7
26 struct AnonBitfieldQualifiers
{
27 const unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}}
28 volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}}
29 const volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}}
32 const unsigned i1
: 1;
33 volatile unsigned i2
: 1;
34 const volatile unsigned i3
: 1;
38 namespace dr2233
{ // dr2233: 11
39 #if __cplusplus >= 201103L
40 template <typename
... T
>
41 void f(int i
= 0, T
... args
) {}
43 template <typename
... T
>
44 void g(int i
= 0, T
... args
, T
... args2
) {}
46 template <typename
... T
>
47 void h(int i
= 0, T
... args
, int j
= 1) {}
49 template <typename
... T
, typename
... U
>
50 void i(int i
= 0, T
... args
, int j
= 1, U
... args2
) {}
52 template <class... Ts
>
53 void j(int i
= 0, Ts
... ts
) {}
56 void j
<int>(int i
, int j
) {}
59 void j(int, int, int);
62 void j(int, int, int, int);
65 // Ensure instantiating the templates works.
76 i
<int, int>(1, 2, 3, 4, 5);
83 namespace MultilevelSpecialization
{
84 template<typename
...T
> struct A
{
85 template <T
... V
> void f(int i
= 0, int (&... arr
)[V
]);
88 void A
<int, int>::f
<1, 1>(int i
, int (&arr1a
)[1], int (&arr2a
)[1]) {}
90 // FIXME: I believe this example is valid, at least up to the first explicit
91 // specialization, but Clang can't cope with explicit specializations that
92 // expand packs into a sequence of parameters. If we ever start accepting
93 // that, we'll need to decide whether it's OK for arr1a to be missing its
94 // default argument -- how far back do we look when determining whether a
95 // parameter was expanded from a pack?
96 // -- zygoloid 2020-06-02
97 template<typename
...T
> struct B
{
98 template <T
... V
> void f(int i
= 0, int (&... arr
)[V
]);
100 template<> template<int a
, int b
>
101 void B
<int, int>::f(int i
, int (&arr1
)[a
], int (&arr2
)[b
]) {} // expected-error {{does not match}}
102 template<> template<>
103 void B
<int, int>::f
<1, 1>(int i
, int (&arr1a
)[1], int (&arr2a
)[1]) {}
106 namespace CheckAfterMerging1
{
107 template <typename
... T
> void f() {
108 void g(int, int = 0);
109 void g(int = 0, T
...);
112 void h() { f
<int>(); }
115 namespace CheckAfterMerging2
{
116 template <typename
... T
> void f() {
117 void g(int = 0, T
...);
118 void g(int, int = 0);
121 void h() { f
<int>(); }
124 } // namespace dr2233
126 namespace dr2267
{ // dr2267: no
127 #if __cplusplus >= 201103L
129 struct B
{ explicit B(const A
&); }; // #dr2267-struct-B
132 struct C
{ explicit operator D(); } c
;
135 const B
&b2
{a
}; // FIXME ill-formed
137 // expected-error@-1 {{no viable conversion from 'struct A' to 'const B'}}
138 // expected-note@#dr2267-struct-B {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'struct A' to 'const B &' for 1st argument}}
139 // expected-note@#dr2267-struct-B {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'struct A' to 'B &&' for 1st argument}}
140 // expected-note@#dr2267-struct-B {{explicit constructor is not a candidate}}
143 const D
&d2
{c
}; // FIXME ill-formed
144 const D
&d3(c
); // FIXME ill-formed
148 namespace dr2292
{ // dr2292: 9
149 #if __cplusplus >= 201103L
150 template<typename T
> using id
= T
;
152 p
->template id
<int>::~id
<int>();