Richard Smith | a5bbbfe | 2019-04-18 21:12:54 +0000 | [diff] [blame] | 1 | // 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 | |
| 5 | module; |
| 6 | |
| 7 | #ifdef ERRORS |
| 8 | export int a; // expected-error {{after the module declaration}} |
| 9 | #endif |
| 10 | |
| 11 | #ifndef IMPLEMENTATION |
| 12 | export |
| 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 |
| 18 | module M; |
| 19 | |
| 20 | export int b; // #1 |
| 21 | namespace N { |
| 22 | export int c; // #2 |
| 23 | } |
| 24 | |
| 25 | #ifdef ERRORS |
Richard Smith | e181de7 | 2019-04-22 22:50:11 +0000 | [diff] [blame^] | 26 | namespace { // expected-note 2{{anonymous namespace begins here}} |
| 27 | export int d1; // expected-error {{export declaration appears within anonymous namespace}} |
Richard Smith | a5bbbfe | 2019-04-18 21:12:54 +0000 | [diff] [blame] | 28 | namespace X { |
Richard Smith | e181de7 | 2019-04-22 22:50:11 +0000 | [diff] [blame^] | 29 | export int d2; // expected-error {{export declaration appears within anonymous namespace}} |
Richard Smith | a5bbbfe | 2019-04-18 21:12:54 +0000 | [diff] [blame] | 30 | } |
| 31 | } |
| 32 | |
| 33 | export export int e; // expected-error {{within another export declaration}} |
Richard Smith | e181de7 | 2019-04-22 22:50:11 +0000 | [diff] [blame^] | 34 | export { export int f; } // expected-error {{within another export declaration}} expected-note {{export block begins here}} |
Richard Smith | a5bbbfe | 2019-04-18 21:12:54 +0000 | [diff] [blame] | 35 | |
| 36 | module :private; // expected-note {{private module fragment begins here}} |
| 37 | export int priv; // expected-error {{export declaration cannot be used in a private module fragment}} |
| 38 | #endif |