| 1 |
// The intention of this file to check we could only export declarations in namesapce scope. |
| 2 |
// |
| 3 |
// RUN: %clang_cc1 -std=c++20 %s -verify |
| 4 |
|
| 5 |
export module X; |
| 6 |
|
| 7 |
export template <typename T> |
| 8 |
struct X { |
| 9 |
struct iterator { |
| 10 |
T node; |
| 11 |
}; |
| 12 |
void foo() {} |
| 13 |
template <typename U> |
| 14 |
U bar(); |
| 15 |
}; |
| 16 |
|
| 17 |
export template <typename T> struct X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} |
| 18 |
// expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}} |
| 19 |
export template <typename T> void X<T>::foo(); // expected-error {{cannot export 'foo' as it is not at namespace scope}} |
| 20 |
export template <typename T> template <typename U> U X<T>::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}} |
| 21 |
|
| 22 |
export struct Y { |
| 23 |
struct iterator { |
| 24 |
int node; |
| 25 |
}; |
| 26 |
void foo() {} |
| 27 |
template <typename U> |
| 28 |
U bar(); |
| 29 |
}; |
| 30 |
|
| 31 |
export struct Y::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} |
| 32 |
// expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}} |
| 33 |
export void Y::foo(); // expected-error {{cannot export 'foo' as it is not at namespace scope}} |
| 34 |
export template <typename U> U Y::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}} |
| 35 |
|
| 36 |
export { |
| 37 |
template <typename T> struct X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} |
| 38 |
// expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}} |
| 39 |
struct Y::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} |
| 40 |
// expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}} |
| 41 |
} |