Debian Codegraph @

clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm

raw
1 // RUN: %clang_cc1 -std=c++20 %s -verify -o /dev/null
2 // RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -verify -emit-module-interface -o %t
3 // RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -verify -fmodule-file=A=%t -o /dev/null
4 //
5 // RUN: %clang_cc1 -std=c++20 %s -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null
6 // RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null
7 // RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null
8
9 #if INTERFACE
10 // expected-no-diagnostics
11 export module A;
12 #elif IMPLEMENTATION
13 module A; // #module-decl
14 #ifdef BUILT_AS_INTERFACE
15 // expected-error@-2 {{missing 'export' specifier in module declaration while building module interface}}
16 #define INTERFACE
17 #endif
18 #endif
19
20 #ifndef INTERFACE
21 export int b; // expected-error {{export declaration can only be used within a module purview}}
22 #ifdef IMPLEMENTATION
23 // expected-note@#module-decl {{add 'export' here}}
24 #endif
25 #else
26 export int a;
27 #endif