Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / module / module.interface / p2-2.cpp
blob04904a8d86f27925433bf783f261ee9b379a5d48
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
5 export module X;
7 export template <typename T>
8 struct X {
9 struct iterator {
10 T node;
12 void foo() {}
13 template <typename U>
14 U bar();
17 export template <typename T> struct 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}}
21 export struct Y {
22 struct iterator {
23 int node;
25 void foo() {}
26 template <typename U>
27 U bar();
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}}
34 export {
35 template <typename T> struct 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}}