[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / cxx20-10-2-ex6.cpp
blobcb3bc88e7e72848a7267c39f1eac035696a8f040
1 // Based on C++20 10.2 example 6.
3 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t
5 export module M;
7 static int f(); // expected-note {{previous declaration is here}} #1
8 // error: #1 gives internal linkage
9 export int f(); // expected-error {{cannot export redeclaration 'f' here since the previous declaration has internal linkage}}
10 struct S; // expected-note {{previous declaration is here}} #2
11 // error: #2 gives module linkage
12 export struct S; // expected-error {{cannot export redeclaration 'S' here since the previous declaration has module linkage}}
14 namespace {
15 namespace N {
16 extern int x; // expected-note {{previous declaration is here}} #3
18 } // namespace
19 // error: #3 gives internal linkage
20 export int N::x; // expected-error {{cannot export redeclaration 'x' here since the previous declaration has internal linkage}}
21 // expected-error@-1 {{declaration of 'x' with internal linkage cannot be exported}}