xref: /llvm-project/clang/test/Parser/cxx2b-init-statement.cpp (revision ba15d186e5cef2620d562c6c9d9a6d570382cd0a)
1*ba15d186SMark de Wever // RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 -Wall %s
2ff013b61SCorentin Jabot // RUN: %clang_cc1 -fsyntax-only -verify=expected,expected-cxx20 -std=c++20 -Wall %s
3ff013b61SCorentin Jabot 
4ff013b61SCorentin Jabot namespace ns {
5ff013b61SCorentin Jabot     int i;
6ff013b61SCorentin Jabot     enum class e {};
7ff013b61SCorentin Jabot }
f()8ff013b61SCorentin Jabot void f() {
9ff013b61SCorentin Jabot 
10*ba15d186SMark de Wever     for (using foo = int;true;); //expected-cxx20-warning {{alias declaration in this context is a C++23 extension}}
11ff013b61SCorentin Jabot 
12*ba15d186SMark de Wever     switch(using foo = int; 0) { //expected-cxx20-warning {{alias declaration in this context is a C++23 extension}}
13ff013b61SCorentin Jabot         case 0: break;
14ff013b61SCorentin Jabot     }
15ff013b61SCorentin Jabot 
16*ba15d186SMark de Wever     if(using foo = int; false) {} //expected-cxx20-warning {{alias declaration in this context is a C++23 extension}}
17ff013b61SCorentin Jabot 
18ff013b61SCorentin Jabot 
19ff013b61SCorentin Jabot     if (using enum ns::e; false){}  // expected-error {{expected '='}}
20ff013b61SCorentin Jabot 
21ff013b61SCorentin Jabot     for (using ns::i; true;);  // expected-error {{expected '='}}
22ff013b61SCorentin Jabot 
23ff013b61SCorentin Jabot     if (using ns::i; false){}  // expected-error {{expected '='}}
24ff013b61SCorentin Jabot 
25ff013b61SCorentin Jabot     switch(using ns::i; 0) {   // expected-error {{expected '='}}
26ff013b61SCorentin Jabot         case 0: break;
27ff013b61SCorentin Jabot     }
28ff013b61SCorentin Jabot 
29ff013b61SCorentin Jabot }
30