xref: /llvm-project/clang/test/Modules/pr61317.cppm (revision da00c60dae0040185dc45039c4397f6e746548e9)
1// From https://github.com/llvm/llvm-project/issues/61317
2// RUN: rm -rf %t
3// RUN: mkdir -p %t
4// RUN: split-file %s %t
5//
6// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
7// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm \
8// RUN:     -fprebuilt-module-path=%t
9// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
10
11// RUN: rm -rf %t
12// RUN: mkdir -p %t
13// RUN: split-file %s %t
14//
15// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.pcm
16// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -o %t/B.pcm \
17// RUN:     -fprebuilt-module-path=%t
18// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
19
20//--- foo.h
21#ifndef _FOO
22#define _FOO
23
24template <typename T> struct Foo {
25  Foo(T f) {}
26};
27
28template <typename T> Foo(T&) -> Foo<T>;
29
30struct Bar {
31  template <typename T>
32    requires requires { Foo{T()}; }
33  void baz() const {}
34};
35
36template <typename T> struct Foo2 {
37  Foo2(T f) {}
38};
39
40struct Bar2 {
41  template <typename T>
42    requires requires { Foo2{T()}; }
43  void baz2() const {}
44};
45
46#endif
47
48//--- A.cppm
49module;
50#include "foo.h"
51export module A;
52export using ::Foo;
53export using ::Bar;
54export using ::Bar2;
55
56//--- B.cppm
57module;
58#include "foo.h"
59export module B;
60export import A;
61
62//--- Use.cpp
63// expected-no-diagnostics
64import A;
65import B;
66void use() {
67  Bar _;
68  _.baz<int>();
69
70  Bar2 __;
71  __.baz2<int>();
72}
73