2 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header-unit-header std-10-6-ex1-decl.h \
8 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header-unit-header std-10-6-ex1-defn.h \
11 // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-6-ex1-stuff.cpp \
14 // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-6-ex1-M1.cpp \
15 // RUN: -fmodule-file=stuff=stuff.pcm -o M1.pcm -fmodule-file=defn.pcm
17 // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-6-ex1-M2.cpp \
18 // RUN: -fmodule-file=stuff=stuff.pcm -o M2.pcm -fmodule-file=decl.pcm
20 // RUN: %clang_cc1 -std=c++20 std-10-6-ex1-use.cpp \
21 // RUN: -fmodule-file=M1=M1.pcm -fmodule-file=M2=M2.pcm -fmodule-file=stuff=stuff.pcm \
22 // RUN: -fsyntax-only -verify
24 //--- std-10-6-ex1-decl.h
27 //--- std-10-6-ex1-defn.h
30 //--- std-10-6-ex1-stuff.cpp
32 export
template <typename T
, typename U
> void foo(T
, U u
) { auto v
= u
; }
33 export
template <typename T
, typename U
> void bar(T
, U u
) { auto v
= *u
; }
35 //--- std-10-6-ex1-M1.cpp
37 import
"std-10-6-ex1-defn.h"; // provides struct X {};
40 export
template <typename T
> void f(T t
) {
45 //--- std-10-6-ex1-M2.cpp
47 import
"std-10-6-ex1-decl.h"; // provides struct X; (not a definition)
50 export
template <typename T
> void g(T t
) {
55 //--- std-10-6-ex1-use.cpp
61 // It is unspecified whether the instantiation of g(0) is valid here.
62 // We choose to make it invalid here.
63 g(0); // expected-error@* {{definition of 'X' must be imported from module}}
64 // expected-note@* {{in instantiation of function template specialization 'bar<int, X *>'}}
65 // expected-note@* {{in instantiation of function template specialization}}
66 // expected-note@* {{definition here is not reachable}}