| 1 |
// RUN: rm -fr %t |
| 2 |
// RUN: mkdir %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -I%t -emit-module-interface -o %t/B.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only %t/A.cppm -I%t -fprebuilt-module-path=%t -verify |
| 7 |
// |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/D.cppm -I%t -emit-module-interface -o %t/D.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only %t/D-part.cppm -I%t -fprebuilt-module-path=%t -verify |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -I%t -emit-reduced-module-interface -o %t/B.pcm |
| 12 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only %t/A.cppm -I%t -fprebuilt-module-path=%t -verify |
| 13 |
// |
| 14 |
// RUN: %clang_cc1 -std=c++20 %t/D.cppm -I%t -emit-reduced-module-interface -o %t/D.pcm |
| 15 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only %t/D-part.cppm -I%t -fprebuilt-module-path=%t -verify |
| 16 |
|
| 17 |
//--- A.cppm |
| 18 |
module; |
| 19 |
export module baz:A; |
| 20 |
import B; |
| 21 |
#include "C.h" |
| 22 |
|
| 23 |
//--- B.cppm |
| 24 |
module; |
| 25 |
|
| 26 |
#include "C.h" |
| 27 |
export module B; |
| 28 |
|
| 29 |
namespace foo { |
| 30 |
export using foo::bar; |
| 31 |
} |
| 32 |
|
| 33 |
//--- C.h |
| 34 |
namespace foo { |
| 35 |
template<class T, class U> struct bar { // expected-error {{declaration of 'bar' in module baz:A follows declaration in the global module}} // expected-note {{previous declaration is here}} |
| 36 |
template<class, class> bar(T, U); |
| 37 |
}; |
| 38 |
template<class T, class U> bar(T, U) -> bar<T, U>; // expected-error {{declaration of '<deduction guide for bar>' in module baz:A follows declaration in the global module}} // expected-note {{previous declaration is here}} |
| 39 |
} |
| 40 |
|
| 41 |
//--- D.cppm |
| 42 |
// Tests that it is still problematic if they are in one module. |
| 43 |
module; |
| 44 |
#include "E.h" |
| 45 |
export module D; |
| 46 |
|
| 47 |
namespace foo { |
| 48 |
export using foo::bar; |
| 49 |
} |
| 50 |
|
| 51 |
//--- D-part.cppm |
| 52 |
export module D:part; |
| 53 |
import D; |
| 54 |
#include "E.h" |
| 55 |
|
| 56 |
//--- E.h |
| 57 |
// another file for simpler diagnostics. |
| 58 |
namespace foo { |
| 59 |
template<class T, class U> struct bar { // expected-error {{declaration of 'bar' in module D:part follows declaration in the global module}} // expected-note {{previous declaration is here}} |
| 60 |
template<class, class> bar(T, U); |
| 61 |
}; |
| 62 |
template<class T, class U> bar(T, U) -> bar<T, U>; // expected-error {{declaration of '<deduction guide for bar>' in module D:part follows declaration in the global module}} // expected-note {{previous declaration is here}} |
| 63 |
} |