| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/p7.cppm -emit-module-interface -o %t/p7.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify |
| 7 |
|
| 8 |
//--- p7.cppm |
| 9 |
export module p7; |
| 10 |
struct 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 |
|
| 31 |
export auto getReachable() { |
| 32 |
return reachable{}; |
| 33 |
} |
| 34 |
|
| 35 |
export enum E1 { e1 }; |
| 36 |
enum E2 { e2 }; |
| 37 |
export using E2U = E2; |
| 38 |
enum E3 { e3 }; |
| 39 |
export E3 func(); |
| 40 |
|
| 41 |
//--- Use.cpp |
| 42 |
import p7; |
| 43 |
void 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 |
|
| 57 |
void test2() { |
| 58 |
auto a = E1::e1; // OK, namespace-scope name E1 is visible and e1 is reachable |
| 59 |
auto b = e1; // OK, namespace-scope name e1 is visible |
| 60 |
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 reachable |
| 63 |
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 reachable |
| 66 |
} |