1// Test case from https://github.com/llvm/llvm-project/issues/60036 2// 3// RUN: rm -rf %t 4// RUN: mkdir -p %t 5// RUN: split-file %s %t 6// 7// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm 8// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm 9// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm 10// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/d.pcm 11// RUN: %clang_cc1 -std=c++20 %t/e.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/e.pcm 12// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/f.pcm 13// RUN: %clang_cc1 -std=c++20 %t/g.cppm -fprebuilt-module-path=%t -verify -fsyntax-only 14// 15// Tests that the behavior is fine with specifying module file with `-fmodule-file`. 16// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm 17// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/b.pcm 18// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/c.pcm 19// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -o %t/d.pcm 20// RUN: %clang_cc1 -std=c++20 %t/e.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ 21// RUN: -fmodule-file=c=%t/c.pcm -fmodule-file=d=%t/d.pcm -o %t/e.pcm 22// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm -fmodule-file=c=%t/c.pcm -fmodule-file=d=%t/d.pcm -o %t/f.pcm 23// RUN: %clang_cc1 -std=c++20 %t/g.cppm -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ 24// RUN: -fmodule-file=c=%t/c.pcm -fmodule-file=d=%t/d.pcm -fmodule-file=e=%t/e.pcm \ 25// RUN: -fmodule-file=f=%t/f.pcm -verify -fsyntax-only 26 27// Test again with reduced BMI 28// RUN: rm -rf %t 29// RUN: mkdir -p %t 30// RUN: split-file %s %t 31// 32// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm 33// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/b.pcm 34// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/c.pcm 35// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/d.pcm 36// RUN: %clang_cc1 -std=c++20 %t/e.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/e.pcm 37// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/f.pcm 38// RUN: %clang_cc1 -std=c++20 %t/g.cppm -fprebuilt-module-path=%t -verify -fsyntax-only 39 40 41//--- a.cppm 42export module a; 43 44export template<typename> 45struct a; 46 47template<typename T> 48struct a<T &> { 49 using type = char; 50}; 51 52//--- b.cppm 53export module b; 54 55import a; 56 57typename a<char &>::type; 58 59//--- c.cppm 60export module c; 61 62import a; 63 64typename a<char &>::type; 65 66//--- d.cppm 67export module d; 68 69export template<typename> 70struct d { 71 d() {} 72 explicit d(int) requires(true) {} 73 d(auto &&) {} 74}; 75 76//--- e.cppm 77export module e; 78 79import d; 80 81auto r = d<int>(); 82 83//--- f.cppm 84export module f; 85 86import a; 87import b; 88import c; 89import d; 90 91template<typename T> 92struct array { 93 friend void fr(array<T> const &) { 94 } 95}; 96 97array() -> array<typename a<char &>::type>; 98 99struct wrap { 100 d<int> m; 101}; 102 103template<typename T> 104int f1(T) { 105 return 1; 106} 107 108void f2() { 109 d<int> view; 110 int x = f1(view); 111 typename a<decltype([x]{}) &>::type; 112 wrap w; 113} 114 115//--- g.cppm 116// expected-no-diagnostics 117export module g; 118 119import e; 120import f; 121