From e181de7f4fe9c75327836e5493c2783bcefc9293 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 22 Apr 2019 22:50:11 +0000 Subject: [c++2a] Implement semantic restrictions for 'export' declarations. llvm-svn: 358932 --- clang/test/CXX/module/module.interface/p5.cpp | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 clang/test/CXX/module/module.interface/p5.cpp (limited to 'clang/test/CXX/module/module.interface/p5.cpp') diff --git a/clang/test/CXX/module/module.interface/p5.cpp b/clang/test/CXX/module/module.interface/p5.cpp new file mode 100644 index 00000000000..c4299dc04fb --- /dev/null +++ b/clang/test/CXX/module/module.interface/p5.cpp @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=c++2a %s -verify -pedantic-errors + +export module p5; + +int a; +static int sa; // expected-note {{target}} +void b(); +static void sb(); // expected-note {{target}} +struct c {}; +enum d {}; +using e = int; +using f = c; +static union { int sg1, sg2; }; // expected-note {{target}} +namespace NS {} + +template int ta; +template static int sta; +template void tb(); +template static void stb(); // expected-note {{target}} +template struct tc {}; +template using te = int; +template using tf = c; + +namespace UnnamedNS { + namespace { + int a; // expected-note {{target}} + static int sa; // expected-note {{target}} + void b(); // expected-note {{target}} + static void sb(); // expected-note {{target}} + struct c {}; // expected-note {{target}} + enum d {}; // expected-note {{target}} + using e = int; + using f = c; + static union { int sg1, sg2; }; // expected-note {{target}} + namespace NS {} + + template int ta; // expected-note {{target}} + template static int sta; // expected-note {{target}} + template void tb(); // expected-note {{target}} + template static void stb(); // expected-note {{target}} + template struct tc {}; // expected-note {{target}} + template using te = int; // expected-note {{target}} + template using tf = c; // expected-note {{target}} + } +} + +export { // expected-note 18{{here}} + using ::a; + using ::sa; // expected-error {{using declaration referring to 'sa' with internal linkage}} + using ::b; + using ::sb; // expected-error {{using declaration referring to 'sb' with internal linkage}} + using ::c; + using ::d; + using ::e; + using ::f; + using ::sg1; // expected-error {{using declaration referring to 'sg1' with internal linkage}} + + using ::ta; + using ::sta; // FIXME {{using declaration referring to 'sta' with internal linkage}} + using ::tb; + using ::stb; // expected-error {{using declaration referring to 'stb' with internal linkage}} + using ::tc; + using ::te; + using ::tf; + namespace NS2 = ::NS; + + namespace UnnamedNS { + using UnnamedNS::a; // expected-error {{internal linkage}} + using UnnamedNS::sa; // expected-error {{internal linkage}} + using UnnamedNS::b; // expected-error {{internal linkage}} + using UnnamedNS::sb; // expected-error {{internal linkage}} + using UnnamedNS::c; // expected-error {{internal linkage}} + using UnnamedNS::d; // expected-error {{internal linkage}} + using UnnamedNS::e; // ok + using UnnamedNS::f; // ok? using-declaration refers to alias-declaration, + // which does not have linkage (even though that then + // refers to a type that has internal linkage) + using UnnamedNS::sg1; // expected-error {{internal linkage}} + + using UnnamedNS::ta; // expected-error {{internal linkage}} + using UnnamedNS::sta; // expected-error {{internal linkage}} + using UnnamedNS::tb; // expected-error {{internal linkage}} + using UnnamedNS::stb; // expected-error {{internal linkage}} + using UnnamedNS::tc; // expected-error {{internal linkage}} + using UnnamedNS::te; // expected-error {{internal linkage}} + using UnnamedNS::tf; // expected-error {{internal linkage}} + namespace NS2 = UnnamedNS::NS; // ok (wording bug?) + } +} -- cgit v1.2.3