xref: /llvm-project/clang/test/SemaCXX/cxx23-init-statement.cpp (revision 1077a343911127452615c6f5441c121de06be6d5)
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 %s
2 
3 namespace GH63627 {
4 template<class T>
ok()5 void ok() {
6   if  (using U = decltype([]{ return 42;}); true) {
7       static_assert(U{}() == 42);
8   }
9   for (using U = decltype([]{ return 42;}); [[maybe_unused]] auto x : "abc") {
10       static_assert(U{}() == 42);
11   }
12   for (using U = decltype([]{ return 42;}); false; ) {
13       static_assert(U{}() == 42);
14   }
15 }
16 
17 template<class T>
err()18 void err() {
19   if  (using U = decltype([]{}.foo); true) {}  // expected-error {{no member named 'foo'}}
20 
21   for (using U = decltype([]{}.foo);          // expected-error {{no member named 'foo'}}
22        [[maybe_unused]] auto x : "abc") { }
23 
24   for (using U = decltype([]{}.foo);          // expected-error {{no member named 'foo'}}
25        false ; ) { }
26 };
27 
test()28 void test() {
29   ok<int>();
30   err<int>(); // expected-note {{in instantiation of function template specialization 'GH63627::err<int>'}}
31 }
32 
33 }
34