Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions clang/test/CXX/module/module.interface/p1.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
// RUN: %clang_cc1 -std=c++2a %s -DERRORS -verify
// RUN: %clang_cc1 -std=c++2a %s -emit-module-interface -o %t.pcm
// RUN: %clang_cc1 -std=c++2a %s -fmodule-file=M=%t.pcm -DIMPLEMENTATION -verify -Db=b2 -Dc=c2
// RUN: rm -rf %t
// RUN: split-file %s %t

module;
// RUN: %clang_cc1 -std=c++2a %t/errors.cpp -verify
// RUN: %clang_cc1 -std=c++2a %t/M.cppm -emit-module-interface -o %t/M.pcm
// RUN: %clang_cc1 -std=c++2a %t/impl.cpp -fmodule-file=M=%t/M.pcm -verify

#ifdef ERRORS
//--- errors.cpp
module;
export int a; // expected-error {{export declaration can only be used within a module purview}}
#endif

#ifndef IMPLEMENTATION
export
#else
// expected-error@#1 {{export declaration can only be used within a module purview}}
// expected-error@#2 {{export declaration can only be used within a module purview}}
// expected-note@+2 1+{{add 'export'}}
#endif
module M;

export module M;
export int b; // #1
namespace N {
export int c; // #2
}

#ifdef ERRORS
namespace { // expected-note 2{{anonymous namespace begins here}}
export int d1; // expected-error {{export declaration appears within anonymous namespace}}
namespace X {
Expand All @@ -35,4 +26,19 @@ export { export int f; } // expected-error {{within another export declaration}}

module :private; // expected-note {{private module fragment begins here}}
export int priv; // expected-error {{export declaration cannot be used in a private module fragment}}
#endif

//--- M.cppm
export module M;
export int b;
namespace N {
export int c;
}

//--- impl.cpp
module M; // #M

export int b2; // expected-error {{export declaration can only be used within a module purview}}
namespace N {
export int c2; // expected-error {{export declaration can only be used within a module purview}}
}
// expected-note@#M 2+{{add 'export'}}
Loading