67 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 %t/p7.cppm -emit-module-interface -o %t/p7.pcm6// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify7 8//--- p7.cppm9export module p7;10struct reachable {11 constexpr static int sv = 43;12 int value = 44;13 14 static int getValue() { return 43; }15 int get() { return 44; }16 17 template <typename T>18 static bool templ_get(T t) { return false; }19 typedef int typedef_type;20 using using_type = int;21 template <typename T>22 using templ_using_type = int;23 bool operator()() {24 return false;25 }26 27 enum E { a,28 b };29};30 31export auto getReachable() {32 return reachable{};33}34 35export enum E1 { e1 };36enum E2 { e2 };37export using E2U = E2;38enum E3 { e3 };39export E3 func();40 41//--- Use.cpp42import p7;43void test() {44 auto reachable = getReachable();45 int a = decltype(reachable)::sv;46 int b = decltype(reachable)::getValue();47 int c = reachable.value;48 int d = reachable.get();49 int e = decltype(reachable)::a;50 int f = reachable.templ_get(a);51 typename decltype(reachable)::typedef_type g;52 typename decltype(reachable)::using_type h;53 typename decltype(reachable)::template templ_using_type<int> j;54 auto value = reachable();55}56 57void test2() {58 auto a = E1::e1; // OK, namespace-scope name E1 is visible and e1 is reachable59 auto b = e1; // OK, namespace-scope name e1 is visible60 auto c = E2::e2; // expected-error {{use of undeclared identifier 'E2'}}61 auto d = e2; // expected-error {{use of undeclared identifier 'e2'}}62 auto e = E2U::e2; // OK, namespace-scope name E2U is visible and E2::e2 is reachable63 auto f = E3::e3; // expected-error {{use of undeclared identifier 'E3'}}64 auto g = e3; // expected-error {{use of undeclared identifier 'e3'}}65 auto h = decltype(func())::e3; // OK, namespace-scope name f is visible and E3::e3 is reachable66}67