1 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
2 // RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify
5 namespace dr2621
{ // dr2621: yes
9 using enum E_t
; // typedef ok
15 using enum E
; // expected-error {{unknown type name E}}
19 namespace dr2628
{ // dr2628: no open
20 // this was reverted for the 16.x release
21 // due to regressions, see the issue for more details:
22 // https://github.com/llvm/llvm-project/issues/60777
24 template <bool A
= false, bool B
= false>
26 // The expected notes below should be removed when dr2628 is fully implemented again
27 constexpr foo() requires (!A
&& !B
) = delete; // expected-note {{candidate function [with A = false, B = false]}} #DR2628_CTOR
28 constexpr foo() requires (A
|| B
) = delete; // expected-note {{candidate function [with A = false, B = false]}}
32 // The FIXME's below should be the expected errors when dr2628 is
33 // fully implemented again.
34 // FIXME-expected-error {{call to deleted}}
35 foo fooable
; // expected-error {{ambiguous deduction for template arguments of 'foo'}}
36 // FIXME-expected-note@#DR2628_CTOR {{marked deleted here}}
41 namespace dr2631
{ // dr2631: 16
57 namespace dr2635
{ // dr2635: 16
59 concept UnaryC
= true;
60 template<typename T
, typename U
>
61 concept BinaryC
= true;
63 struct S
{ int i
, j
; };
70 // expected-error@+1{{decomposition declaration cannot be declared with constrained 'auto'}}
71 UnaryC
auto [a
, b
] = get_S();
72 // expected-error@+1{{decomposition declaration cannot be declared with constrained 'auto'}}
73 BinaryC
<int> auto [c
, d
] = get_S();
78 // expected-error@+1{{decomposition declaration cannot be declared with constrained 'auto'}}
79 UnaryC
auto [a
, b
] = get_T
<T
>();
80 // expected-error@+1{{decomposition declaration cannot be declared with constrained 'auto'}}
81 BinaryC
<T
> auto [c
, d
] = get_T
<T
>();
87 namespace dr2640
{ // dr2640: 16
89 int \N
{Λ
} = 0; //expected-error {{'Λ' is not a valid Unicode character name}} \
90 //expected-error {{expected unqualified-id}}
91 const char* emoji
= "\N{🤡}"; // expected-error {{'🤡' is not a valid Unicode character name}} \
92 // expected-note 5{{did you mean}}
96 int x
= dr2640_a\N
{abc
}); // expected-error {{'abc' is not a valid Unicode character name}}
97 int y
= dr2640_a\N
{LOTUS
}); // expected-error {{character <U+1FAB7> not allowed in an identifier}} \
98 // expected-error {{use of undeclared identifier 'dr2640_a🪷'}} \
99 // expected-error {{extraneous ')' before ';'}}
104 namespace dr2644
{ // dr2644: yes
106 auto z
= [a
= 42](int a
) { // expected-error {{a lambda parameter cannot shadow an explicitly captured entity}} \
107 // expected-note {{variable 'a' is explicitly captured here}}
113 #if __cplusplus >= 202302L
114 namespace dr2650
{ // dr2650: yes
115 template <class T
, T
> struct S
{};
116 template <class T
> int f(S
<T
, T
{}>*); // expected-note {{type 'X' of non-type template parameter is not a structural type}}
120 int i0
= f
<X
>(0); //expected-error {{no matching function for call to 'f'}}
124 #if __cplusplus >= 202302L
125 namespace dr2653
{ // dr2653: 18
126 struct Test
{ void f(this const auto& = Test
{}); };
127 // expected-error@-1 {{the explicit object parameter cannot have a default argument}}
128 auto L
= [](this const auto& = Test
{}){};
129 // expected-error@-1 {{the explicit object parameter cannot have a default argument}}
133 namespace dr2654
{ // dr2654: 16
136 volatile int brachiosaur
;
137 brachiosaur
+= neck
; // OK
138 brachiosaur
-= neck
; // OK
139 brachiosaur
|= neck
; // OK
143 namespace dr2681
{ // dr2681: 17
144 using size_t = decltype(sizeof(int));
146 template<class T
, size_t N
>
150 template<class T
, size_t N
>
155 struct J
{ // expected-note 3{{candidate}}
156 unsigned char array
[N
];
161 static_assert(__is_same(decltype(h
), H
<char, 4>)); // Not H<const char, 4>
162 static_assert(__is_same(decltype(i
), I
<char, 4>));
164 J j
= { "ghi" }; // expected-error {{no viable constructor or deduction guide}}
167 namespace dr2672
{ // dr2672: 18 open
169 void f(T
) requires requires
{ []() { T::invalid
; } (); }; // expected-error{{type 'int' cannot be used prior to '::'}}
170 // expected-note@-1{{while substituting into a lambda expression here}}
171 // expected-note@-2{{in instantiation of requirement here}}
172 // expected-note@-3{{while substituting template arguments into constraint expression here}}
176 void bar(T
) requires requires
{
177 decltype([]() -> T
{})::foo();
182 f(0); // expected-note {{while checking constraint satisfaction for template 'f<int>' required here}}
183 // expected-note@-1 {{in instantiation of function template specialization}}
187 #if __cplusplus >= 202302L
188 namespace dr2687
{ // dr2687: 18
192 void h(this const S
&, int);
196 (&S::f
)(1); // expected-error {{called object type 'void (dr2687::S::*)(int)' is not a function or function pointer}}