[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg8xx.cpp
blob38bff3adf262a8ddd9d51c5df33811910c6cd763
1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
7 // RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
9 namespace cwg820 { // cwg820: 2.7
10 export template <class T> struct B {};
11 // cxx98-17-warning@-1 {{exported templates are unsupported}}
12 // since-cxx20-error@-2 {{export declaration can only be used within a module purview}}
13 export template<typename T> void f() {}
14 // cxx98-17-warning@-1 {{exported templates are unsupported}}
15 // since-cxx20-error@-2 {{export declaration can only be used within a module purview}}
18 namespace cwg873 { // cwg873: 3.0
19 #if __cplusplus >= 201103L
20 template <typename T> void f(T &&);
21 template <> void f(int &) = delete; // #cwg873-lvalue-ref
22 template <> void f(int &&) = delete; // #cwg873-rvalue-ref
23 void g(int i) {
24 f(i); // calls f<int&>(int&)
25 // since-cxx11-error@-1 {{call to deleted function 'f'}}
26 // since-cxx11-note@#cwg873-lvalue-ref {{candidate function [with T = int &] has been implicitly deleted}}
27 f(0); // calls f<int>(int&&)
28 // since-cxx11-error@-1 {{call to deleted function 'f'}}
29 // since-cxx11-note@#cwg873-rvalue-ref {{candidate function [with T = int] has been implicitly deleted}}
31 #endif
32 } // namespace cwg873
34 // cwg882: 3.5
35 #if __cplusplus >= 201103L
36 int main() = delete;
37 // since-cxx11-error@-1 {{'main' is not allowed to be deleted}}
38 #endif