aboutsummaryrefslogtreecommitdiff
path: root/clang/test/CXX/module/module.interface/p2-2.cpp
blob: 8607ea47ac1ce309b1b8e29b7c25d0955f895d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// The intention of this file to check we could only export declarations in namesapce scope.
//
// RUN: %clang_cc1 -std=c++20 %s -verify

export module X;

export template <typename T>
struct X {
  struct iterator {
    T node;
  };
  void foo() {}
  template <typename U>
  U bar();
};

export template <typename T> struct X<T>::iterator;               // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
                                                                  // expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}}
export template <typename T> void X<T>::foo();                    // expected-error {{cannot export 'foo' as it is not at namespace scope}}
export template <typename T> template <typename U> U X<T>::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}}

export struct Y {
  struct iterator {
    int node;
  };
  void foo() {}
  template <typename U>
  U bar();
};

export struct Y::iterator;               // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
                                         // expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}}
export void Y::foo();                    // expected-error {{cannot export 'foo' as it is not at namespace scope}}
export template <typename U> U Y::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}}

export {
  template <typename T> struct X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
                                               // expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}}
  struct Y::iterator;                          // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
                                               // expected-error@-1 {{forward declaration of struct cannot have a nested name specifier}}
}