| 1 |
// { dg-additional-options "-fmodules-ts" } |
| 2 |
// { dg-module-cmi !M } |
| 3 |
|
| 4 |
export module M; |
| 5 |
|
| 6 |
// Same as a linkage-1 except within an anonymous namespace; |
| 7 |
// now these declarations cannot possibly be defined outside this TU, |
| 8 |
// so we should error. |
| 9 |
|
| 10 |
namespace { |
| 11 |
auto f() { |
| 12 |
struct A {}; |
| 13 |
return A{}; |
| 14 |
} |
| 15 |
decltype(f()) g(); // { dg-error "used but never defined" } |
| 16 |
|
| 17 |
struct {} s; |
| 18 |
decltype(s) h(); // { dg-error "used but never defined" } |
| 19 |
} |
| 20 |
|
| 21 |
export void use() { |
| 22 |
g(); |
| 23 |
h(); |
| 24 |
} |
| 25 |
|
| 26 |
// Additionally, unnamed types have no linkage but are also TU-local, and thus |
| 27 |
// cannot be exposed in a module interface unit. The non-TU-local entity 's' |
| 28 |
// here is an exposure of this type. |
| 29 |
struct {} s; // { dg-error "exposes TU-local entity" } |