aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Modules/pr60890.cppm
blob: b1d9114bf1ebee2a8396218a1393d928d68af9d1 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// https://github.com/llvm/llvm-project/issues/60890
//
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -fprebuilt-module-path=%t -o %t/b.pcm
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/c.cppm -fprebuilt-module-path=%t -o %t/c.pcm
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -emit-llvm-only

// Test again with reduced BMI
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/a.cppm -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/b.cppm -fprebuilt-module-path=%t -o %t/b.pcm
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/c.cppm -fprebuilt-module-path=%t -o %t/c.pcm
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -emit-llvm-only

//--- a.cppm
export module a;
 
export template<typename T>
struct a {
	friend void aa(a x) requires(true) {}
	void aaa() requires(true) {}
};

export template struct a<double>;

export template<typename T>
void foo(T) requires(true) {}

export template void foo<double>(double);

export template <typename T>
class A {
	friend void foo<>(A);
};

//--- b.cppm
export module b;

import a;

void b() {
    a<int> _;
	a<double> __;
}

//--- c.cppm
export module c;

import a;

struct c {
	void f() const {
		a<int> _;
		aa(_);
		_.aaa();

		a<double> __;
		aa(__);
		__.aaa();

		foo<int>(5);
		foo<double>(3.0);
		foo(A<int>());
	}
};

//--- d.cpp
// expected-no-diagnostics
import a;
import b;
import c;

void d() {
	a<int> _;
	aa(_);
	_.aaa();

	a<double> __;
	aa(__);
	__.aaa();

	foo<int>(5);
	foo<double>(3.0);
	foo(A<int>());
}