[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / cxx20-10-2-ex1.cpp
blob0cd6f77466f4bcb75103be77603a802da3ce8a99
1 // Based on C++20 10.2 example 1.
3 // RUN: rm -rf %t
4 // RUN: mkdir -p %t
5 // RUN: split-file %s %t
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std-10-2-ex1-tu1.cpp \
8 // RUN: -pedantic-errors -verify -o %t/m1.pcm
10 //--- std-10-2-ex1.h
11 export int x;
13 //--- std-10-2-ex1-tu1.cpp
14 module;
16 #include "std-10-2-ex1.h"
17 // expected-error@std-10-2-ex1.h:* {{export declaration can only be used within a module purview}}
19 export module M1;
20 export namespace {} // expected-error {{anonymous namespaces cannot be exported}}
21 export namespace { // expected-error {{anonymous namespaces cannot be exported}}
22 int a1;
24 namespace { // expected-note {{anonymous namespace begins here}}
25 export int a2; // expected-error {{export declaration appears within anonymous namespace}}
27 export static int b; // expected-error {{declaration of 'b' with internal linkage cannot be exported}}
28 export int f(); // OK
30 export namespace N {} // namespace N
31 export using namespace N; // No diagnostic after P2615R1 DR