brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 8607ea4 Raw
42 lines · cpp
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 -verify4 5export module X;6 7export template <typename T>8struct X {9  struct iterator {10    T node;11  };12  void foo() {}13  template <typename U>14  U bar();15};16 17export 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}}19export template <typename T> void X<T>::foo();                    // expected-error {{cannot export 'foo' as it is not at namespace scope}}20export template <typename T> template <typename U> U X<T>::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}}21 22export struct Y {23  struct iterator {24    int node;25  };26  void foo() {}27  template <typename U>28  U bar();29};30 31export 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}}33export void Y::foo();                    // expected-error {{cannot export 'foo' as it is not at namespace scope}}34export template <typename U> U Y::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}}35 36export {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}42