summaryrefslogtreecommitdiffstats
path: root/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp
blob: 52f45f578da749f1f9c5a47c914bfb9926b3e1c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// RUN: %clang_cc1 -fmodules-ts %s -verify -o /dev/null
// RUN: %clang_cc1 -fmodules-ts %s -DINTERFACE -verify -emit-module-interface -o %t
// RUN: %clang_cc1 -fmodules-ts %s -DIMPLEMENTATION -verify -fmodule-file=%t -o /dev/null
//
// RUN: %clang_cc1 -fmodules-ts %s -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null
// RUN: %clang_cc1 -fmodules-ts %s -DINTERFACE -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null
// RUN: %clang_cc1 -fmodules-ts %s -DIMPLEMENTATION -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null

#if INTERFACE
// expected-no-diagnostics
export module A;
#elif IMPLEMENTATION
module A; // #module-decl
 #ifdef BUILT_AS_INTERFACE
  // expected-error@-2 {{missing 'export' specifier in module declaration while building module interface}}
  #define INTERFACE
 #endif
#else
 #ifdef BUILT_AS_INTERFACE
  // expected-error@1 {{missing 'export module' declaration in module interface unit}}
 #endif
#endif

#ifndef INTERFACE
export int b; // expected-error {{export declaration can only be used within a module interface unit}}
#ifdef IMPLEMENTATION
// expected-note@#module-decl {{add 'export' here}}
#endif
#else
export int a;
#endif