blob: 0947b81915eb19bc23cdd25b7747523f2af40660 [file] [log] [blame]
Richard Smitha5bbbfe2019-04-18 21:12:54 +00001// RUN: %clang_cc1 -std=c++2a %s -DERRORS -verify
2// RUN: %clang_cc1 -std=c++2a %s -emit-module-interface -o %t.pcm
3// RUN: %clang_cc1 -std=c++2a %s -fmodule-file=%t.pcm -DIMPLEMENTATION -verify -Db=b2 -Dc=c2
4
5module;
6
7#ifdef ERRORS
8export int a; // expected-error {{after the module declaration}}
9#endif
10
11#ifndef IMPLEMENTATION
12export
13#else
14// expected-error@#1 {{can only be used within a module interface unit}}
15// expected-error@#2 {{can only be used within a module interface unit}}
16// expected-note@+2 1+{{add 'export'}}
17#endif
18module M;
19
20export int b; // #1
21namespace N {
22 export int c; // #2
23}
24
25#ifdef ERRORS
Richard Smithe181de72019-04-22 22:50:11 +000026namespace { // expected-note 2{{anonymous namespace begins here}}
27 export int d1; // expected-error {{export declaration appears within anonymous namespace}}
Richard Smitha5bbbfe2019-04-18 21:12:54 +000028 namespace X {
Richard Smithe181de72019-04-22 22:50:11 +000029 export int d2; // expected-error {{export declaration appears within anonymous namespace}}
Richard Smitha5bbbfe2019-04-18 21:12:54 +000030 }
31}
32
33export export int e; // expected-error {{within another export declaration}}
Richard Smithe181de72019-04-22 22:50:11 +000034export { export int f; } // expected-error {{within another export declaration}} expected-note {{export block begins here}}
Richard Smitha5bbbfe2019-04-18 21:12:54 +000035
36module :private; // expected-note {{private module fragment begins here}}
37export int priv; // expected-error {{export declaration cannot be used in a private module fragment}}
38#endif