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 }; fooX12 void foo() {} 13 template <typename U> 14 U bar(); 15 }; 16 17 export template <typename T> X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} 18 export template <typename T> void X<T>::foo(); // expected-error {{cannot export 'foo' as it is not at namespace scope}} 19 export template <typename T> template <typename U> U X<T>::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}} 20 21 export struct Y { 22 struct iterator { 23 int node; 24 }; fooY25 void foo() {} 26 template <typename U> 27 U bar(); 28 }; 29 30 export struct Y::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} 31 export void Y::foo(); // expected-error {{cannot export 'foo' as it is not at namespace scope}} 32 export template <typename U> U Y::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}} 33 34 export { 35 template <typename T> X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} 36 struct Y::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}} 37 } 38