1 // Based on C++20 10.2 example 5.
5 // RUN: split-file %s %t
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std-10-2-ex5-tu1.cpp \
10 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std-10-2-ex5-tu2.cpp \
11 // RUN: -fmodule-file=M=%t/M.pcm -o %t/tu-2.o
13 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std-10-2-ex5-tu3.cpp \
14 // RUN: -fmodule-file=M=%t/M.pcm -verify -o %t/main.o
16 // Test again with reduced BMI.
18 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std-10-2-ex5-tu1.cpp \
21 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std-10-2-ex5-tu2.cpp \
22 // RUN: -fmodule-file=M=%t/M.pcm -o %t/tu-2.o
24 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std-10-2-ex5-tu3.cpp \
25 // RUN: -fmodule-file=M=%t/M.pcm -verify -o %t/main.o
28 //--- std-10-2-ex5-tu1.cpp
37 export
void f(S
); // OK
40 export
struct A
; // A exported as incomplete
42 export
auto rootFinder(double a
) {
43 return [=](double x
) { return (x
+ a
/ x
) / 2; };
45 export
const int n
= 5; // OK, n has external linkage
47 //--- std-10-2-ex5-tu2.cpp
54 //--- std-10-2-ex5-tu3.cpp
59 X::f(); // OK, X is exported and definition of X is reachable
60 X::Y y
; // OK, X::Y is exported as a complete type
61 auto f
= rootFinder(2); // OK
62 // error: A is incomplete
63 return A
{45}.value
; // expected-error {{invalid use of incomplete type 'A'}}
64 // expected-error@-1 {{member access into incomplete type 'A'}}
65 // expected-note@std-10-2-ex5-tu1.cpp:12 2{{forward declaration of 'A'}}